• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 18
  • 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

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • 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
  • 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

 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic