When I use session in struts, is it OK if I keep set scope="request" in the <action> tag, and in each Action class I write "HttpSession session = request.getSession(); session.setAttribute("key", "value");" ? The reason is I don't want to set so many forms in the session because I don't need all of the information stored in the form. I will selectively store some useful objects in the session. Is this approach OK ? or do I have to set scope="session" as a must-do ?
Artemesia, This is fine. It sounds like you recognize that you want the forms in the request while other info should be available everywhere (aka in the session.) This is common for things like a username.
Originally posted by Jeanne Boyarsky: Artemesia, This is fine. It sounds like you recognize that you want the forms in the request while other info should be available everywhere (aka in the session.) This is common for things like a username.
actually, another reason why I prefer to set "scope=request" for each <action> tag is --- everytime when I need to get a specific variable in my action business method, I need to retrieve that form first and then get the field, tedious.
Two more question I want to confirm --
1. Is I use session in the Action class, I should use "URL encode" for the "action=" part in the JSP's pages' <FORM action=".."> . Right ? I don't need to change anything or worry about the "path=/myJSp" part, right ? if we use "scope=session' for every "action" in struts-config.xml
2. Assume I set "scope=session" in the struts-config.xml, if I have the following scenario --
On Page1, pick choice a), go to Register.jsp, then go to Checkout.jsp On Page1, pick choice b), go to Checkout.jsp, then go to view.jsp
if I go through the first path to Checkout.jsp, and then click back to Page1 and start the second, when I get to Checkout.jsp, this time the "CheckoutForm" stored in the session will be replaced by the current one, right ? i.e. the "FormBean" stored in the session can be replaced everytime user pick different things and resubmit, as long as the session is being valid. AM I right ?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com