This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Other Open Source Projects and the fly likes sessions always null when using httpunit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "sessions always null when using httpunit" Watch "sessions always null when using httpunit" New topic
Author

sessions always null when using httpunit

O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Basiscly i have a struts application whereby each action is authenticated. So if i make a request this is what happens

- Enter URL
- Servlet validates that user is valid by checking the user's details currently on user's session or authenticate user from the database based on the user logged on the desktop(If session does not exist).

Now i would like to test my application using httpunit but i cant seem to be able to access the sessions.

I write this simple example


It works fine but the response i get is my "Access Denied" page. The findProductsStart Action does authenticate the user through the session. I did debug the above code and it showed that session is null. If i load the same action from the browser everything works fine.

Does anyone have any idea why this doesnt work?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41586
    
  54
If findProductsStart does the right thing on the server, yet still returns an Access Denied page, then you'd have to debug the server logic to see where the HttpUnit access differs from the browser access.


Ping & DNS - my free Android networking tools app
O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Thanks for your reply.

I found that the problem was that there was no session being created. The session was created when the user access the main page. Accessing the above page meant that there was no session so access was denied.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sessions always null when using httpunit