aspose file tools*
The moose likes Struts and the fly likes Form Variables vs Session Variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Form Variables vs Session Variables" Watch "Form Variables vs Session Variables" New topic
Author

Form Variables vs Session Variables

Pavan Kumar
Greenhorn

Joined: Jun 08, 2005
Posts: 23
Hi,

Can anyone tell me whether its better to use Action form variables or variables in session when we want to transfer data between Action class and JSP? Also please list the advantages of using either one of them.
Thanks in advance.

- Pavan.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
What Action form variables??? Are you talking about Struts here?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Pavan Kumar
Greenhorn

Joined: Jun 08, 2005
Posts: 23
I meant Struts Action Form.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I prefer to use variables defined on my action form. At a minimum this gives the JSP developer a place to look up the name of the properties. Also, if I had a value in my Action that I needed to display on my jsp I would store it in the request before I stored it in session.

- Brent
Manuel Jordan
Ranch Hand

Joined: Sep 29, 2006
Posts: 125
Hello

well a normal ActionForm or ValidatorForm is like a pojo, all the simple variables should be type String , the common scope is request

but you can create special variables with scope session before load a jsp
(maybe a list for a html:select), why?, because if you working with validation and detects any error, its create a new request and lost the variable that represents a List, of course that you have a variable or property that represents the value selected of the List (i had this problem if i dont use session scope for the list)

if exist another better way, please let me know

Regards
Manuel
[ October 08, 2006: Message edited by: Manuel Jordan ]

kill your pride, share your knowledge with all
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form Variables vs Session Variables
 
Similar Threads
how to communicate between struts and session
Action Class member variables in Session Struts2
Using DispatchAction ,error whe nusing request scope
Putting a modeldriven object into session
saving session variable in drop down list