Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form Variables vs Session Variables

 
Pavan Kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Action form variables??? Are you talking about Struts here?
 
Pavan Kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I meant Struts Action Form.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic