wood burning stoves 2.0*
The moose likes Struts and the fly likes Use of Struts2 tag in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Use of Struts2 tag in JSP" Watch "Use of Struts2 tag in JSP" New topic
Author

Use of Struts2 tag in JSP

Tarun Oohri
Ranch Hand

Joined: Feb 20, 2013
Posts: 172
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

Joined: Oct 25, 2009
Posts: 5
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

Joined: Oct 25, 2009
Posts: 5
Dear Tarun
Dont try to set username in jsp page. Your Action class should implements SessionAware interface and override a method setSession() method.



 
Consider Paul's rocket mass heater.
 
subject: Use of Struts2 tag in JSP
 
Similar Threads
Struts2 show object attributes in jsp.
Struts2 iterator
Pagination in Struts2
Struts2 iterator
STRUTS2 Dynamic data is not updated