File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to store values in session using struts 2 and then how to retrieve values in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to store values in session using struts 2 and then how to retrieve values in a jsp" Watch "How to store values in session using struts 2 and then how to retrieve values in a jsp" New topic
Author

How to store values in session using struts 2 and then how to retrieve values in a jsp

Prashant K. Singh
Greenhorn

Joined: May 11, 2009
Posts: 18
Hi dear,

I have created the following action class to store values in session. Please tell me if this procedure is correct



Also I am using the following jsp to retrieve values from the session but i am getting null values. Please analyse



Prashant Singh
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You've put the string "details" into session (line 95).

You also appear to be putting a new instance of the action itself into session--this is rather unusual. Normally you'd want to use a simple DTO.

It's also not clear to me if this needs to be in session, or just needs to be usable on the JSP--action properties are available in the JSP by default as long as they have a public accessor.

Lastly, in general, it's best to avoid doing that type of database work in the action itself--that logic belongs in a service which can then be use *by* the action.
Prashant K. Singh
Greenhorn

Joined: May 11, 2009
Posts: 18
Hi,

I changed my .jsp logic and now I am able to print the values

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to store values in session using struts 2 and then how to retrieve values in a jsp