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

Struts2 and accessing session object from JSP?

 
André-John Mas
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added an object to the session map from within my ActionSupport class. I would like to know display it in my page. I am doing something of sorts:

ActionSupport class (implements SessionAware):

sessionMap.put("user",userInstance);

JSP:

<s roperty value="#session.user.firstName"/>

Though non of this seems to work. Any help would be appreciated.
 
André-John Mas
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further investigation shows that indicating my class as implementing SessionAware is not sufficient, since the map never contains the value next time the action is called. What am I missing?
 
Nishan Patel
Ranch Hand
Posts: 689
Eclipse IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi...

Why you use Map for user session.

It is better to use direct like.

HttpSession session = request.getSession (true);

session.setAttribute ("user", userList.get(0));

and then you can access it

<s roperty value="#session.user.firstName"/>

Thanks,
Nishan Patel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic