In order to access session, you need access to object HttpServletRequest.
ActionForm does not have access to HttpServletRequest hence you cant access , session over here. In Action class, only execute method is passed object HttpServletRequest, hence apart from execute, its not possible to access session.
However following places you can access session variable using request object. see Action class documentation to find what method have access to request object. There are more than 10 methods like that.
HTH V [ May 02, 2008: Message edited by: Vishal Matere ]
But only in execute() we can get request. I am integrating Ajax DWR1.0 into struts. When JSP is triggered by drop down list, a xmlHTTPrequest is sent back to server. I mapped a method in action class to process data. I need the information in session object to access data base and then return the data back to next drop down list in same JSP. But How do I access session object from this method (not execute() in action).
Joined: Jan 22, 2008
Originally posted by xuebin gong: I mapped a method in action class to process data
Can you tell me, method signature for this method? I would say pass HttpServletRequest object to this method , thus you can access session object from there.
You can use request processor to pass Request object to your method
If you look closely at the DWR documentation, you will see that if you declare a parameter of type HTTPServletRequest or HTTPSession on your method and declare the method in the DWR config file, the DWR servlet will pass these objects as parameters when it calls your method.