This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Session Issue 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 "Session Issue" Watch "Session Issue" New topic
Author

Session Issue

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
I had declared scope="session" in my struts_Config.xml file. But when I come to my JSP page unless I specify scope="session" in bean:write I am not getting the data.


<action
path="/editRequest"
attribute="RequestForm"
name="RequestForm"
scope="session"
input="/jsp/ViewRequest.jsp"
type="com.abc.xyz.ijk.action.request.EditRequestAction">
<forward name="success" path="/jsp/request/jsp/Request.jsp" />
</action>

JSP page

<bean:write name="RequestForm" property="requestOriginator" scope="session"/>



If I explicitly use session.setAttribte("RequestForm") in my EditRequestAction then it is working perfectly without specify scope="session" in struts_Config

Please let me know how to do it with scope="session" struts_Config and without explicitly setting the session attribute in action class and using scope="session" in jsp page.

[ September 01, 2007: Message edited by: Vishnu Prakash ]


Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It's important to realize that session is the default scope for a Struts action, so whether you specify scope="session" or simply omit the scope attribute, the result will be the same.

As to why your bean:write doesn't show anything unless you specify scope="session", I have no idea. A bean write tag will search all scopes for the name you give, and will display it if it's found.


Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Session Issue
 
Similar Threads
How to close the session in struts.confiq.xml
Getting org.xml.sax.SAXParseException
Display Check Boxes & Dropdowns in Struts with search results
logic:match , logic:notEqual not working
javax.servlet.ServletException:javax.servlet.jsp.JspException: Cannot find bean: "riga" in any scope