File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 39548
    
  27
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 - updated with new look and Ping home screen widget
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
 
Similar Threads
HttpUnit and Proxy Server Script
JBoss/Tomcat/IIS Authentication error
sensing submit in servlet
retrieving a session
Session problem