File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Prashant K. Singh
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic