Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Object in struts2

 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried the example to get session object from [url]http://www.roseindia.net/struts/struts2/struts2ajax/struts2-session.shtml
[/url]
Instead of using SessionAware
i tried to get session object as below
ActionContext context =ActionContext.getContext();
context.getSession().put("ret", "welcome1")

It was not working.

Can we get the session object in such a way?
if it is possible i am unable to get the result in JSP page.
<s:property value="#session.ret" />
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using SessionAware is a better way to do this, though.

Without knowing more about the flow, config, and code, it'll be hard to help--what you're doing should work.
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the above post . There was a logical error in my code.

Both are working fine

1)Implementing SessionAware

2)ActionContext context=ActionContext.getContext();
context.getSession().put("ret", "welcome1")

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No apologies necessary :)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic