When a browser first requests a page from a web server, the session is
created, so as Wendy said, "it's always there". The creation of the session
has nothing to do with whether the user is authenticated/logged in or not.
This is the way I understand it.

If you are set on using hidden variables here is a bit of info:

Using a hidden variable on a jsp page in Struts is pretty straightforward.
First, you add a variable to the formbean being used on the page with
corresponding setter/getter methods. Then in your jsp page, put something
like this in your form:

<html:hidden name="myFormBean" property="myHiddenRegistrationValue"/>

When the form is submitted, Struts finds a myFormBean object in the
appropriate scope (or instantiates a new one) and stuffs the value of the
hidden variable into myFormBean (using setter method). In other words, it
treats it like all the other form variables by calling the setter methods of
the formbean.

Then in your action class, you can reference the variable using the getter
method of your formbean. 

For multiple pages, you'd have to follow the above guidelines on each page
and most likely programmatically call the setter method in your action
classes between page calls.

Don't use getParameter() to try to get hidden form variables. getParameter()
looks for parameters appended to the request URL --
http://www.myhost.com/do/myAction?param1=1&param2=2. getParameter() will
give you access to param1 and param2.

You can also very easily access the session variables in your action class
like this:

request.getSession().getAttribute("sessionVarName")

Brian Barnett


-----Original Message-----
From: Pani R [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 11, 2004 2:02 PM
To: Struts Users Mailing List
Subject: RE: [OT] - Request against Session

Thanks for the advice Wendy.

I may end up storing all the values in the Session. But, on the other side,
how would I store it in the hidden form variable. I think if I store it in
my hidden variable, then its available to me in the action class via
getParameter() which will return me a String object against my User Defined
Object. Is there any other way to do that?

Pani

--

--------- Original Message ---------

DATE: Wed, 11 Feb 2004 13:27:11
From: Wendy Smoak <[EMAIL PROTECTED]>
To: Struts Users Mailing List <[EMAIL PROTECTED]>
Cc: 

>> From: Pani R [mailto:[EMAIL PROTECTED] 
>> Now, when the un-logged user tries to register, where am I 
>> suppose to store the Registration Values, Session or Request? 
>> Which one will be the better approach and why?
>
>I'm not entirely sure when the session officially gets created, I just
>expect it to be there, and it always is.  If you're going to need
>something across requests, you can either jump through hoops and put it
>in hidden form elements, etc., or just stuff it in the session.  
>
>I tend to treate memory and disk space as infinite resources, which may
>not scale, but works for my purposes.  My vote is to put your values in
>the session and don't look back.  Others may disagree...
>
>-- 
>Wendy Smoak
>Application Systems Analyst, Sr.
>ASU IA Information Resources Management 
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>



____________________________________________________________
Find what you are looking for with the Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp
?SRC=lycos10

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to