Hey, I am really breaking my head to get session object in my action class. When I login to a certain portal, the portal sets the user name to the session object. Now on the portal user clicks on my application which is written in struts2. When I get the session map using sessionaware interface, I get an empty map. I also tried using ServeletrequestAware interfacae to get httprequest and called getSession() on it. Still I am getting empty session.
Can someone tell me how can I get the session which contains username set by the portal? Do I need to change something in struts-config.xml?
Joined: Apr 16, 2008
The portal application sets a value in the HttpSession object. There is a link to another application. When you click on a link, it takes you to the other application. The session object created in the portal application may not be accessible from a separate application. As far as I know, the HttpSession object is only alive for a particular session with a particular application. Once you leave the application to go to another, the session object does not follow you.
Joined: Jul 17, 2008
Hi James, Actually my application is a part of portal and runs in the same JVM. Earlier without using struts2 (when it was plain JSP)I was able to get the session object. So may be I am not getting the session object correctly or may be Struts2 is creating a new session object. What is the correct way of accessing the session object with all its attributes. Please let me know the changes in struts-config also.