Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of Struts2 tag in JSP

 
Tarun Oohri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone
I am trying to get my hands on Struts2, and started getting issues. The scenario is as follows :
1.) Entered a username and password from index.jsp
2.) Action class returns success and is navigated to welcome.jsp
3.) In welcome.jsp :
-- I extracted the username using <s:property value="name"/>
Question : What if i start a session in welcome.jsp and try to set an attribute in session scope . How would i do this ?
session.setAttribute("loggedusername", <s:property value="name"/>);
I know this is wrong but how would we do it ? As the logged in user name is fetched to this page using struts property tag.

Thanks!!!
 
Praveen Reddy Somireddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Tarun
Dont try to set username in jsp page. Your Action class should implements SessionAware interface and override a method setSession() method.



 
Praveen Reddy Somireddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Tarun
Dont try to set username in jsp page. Your Action class should implements SessionAware interface and override a method setSession() method.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic