dcsimg
Associating a javabean property with a Session?? Help quickly! :-)
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   olivia_kyle
Posted On:   Friday, October 17, 2003 07:46 AM

I'm slightly confused as to what it means when application information is associated with the HttpSession. In my application, I create a java object and associate it with the session: HttpSession session = request.getSession(true); session.setAttribute("someName",objectCreated); The user is then directed to the next webpage. On this page, I use getProperty to retrieve some of the bean's attributes (e.g., ). If the user then proceeds to several additional pages, will the bean still be available (e.g., for getProperty purposes) since it was associated with the session? Any help is greatly appreciated!!    More>>

I'm slightly confused as to what it means when application information is associated with the HttpSession.


In my application, I create a java object and associate it with the session:


			
HttpSession session = request.getSession(true);
session.setAttribute("someName",objectCreated);


The user is then directed to the next webpage. On this page, I use getProperty to retrieve some of the bean's attributes (e.g., ).


If the user then proceeds to several additional pages, will the bean still be available (e.g., for getProperty purposes) since it was associated with the session?


Any help is greatly appreciated!!

   <<Less

Re: Associating a javabean property with a Session?? Help quickly! :-)

Posted By:   Joost_Schouten  
Posted On:   Friday, October 17, 2003 07:59 AM

Any object set in the session will stay in the session as long as the session is valid. So if your session invalidates after 10 minutes (600 seconds) you will loose any information stored in this session after 10 minutes of inactivety of your client associated with the session.


So your object in the session will still be available to your client if the request requiring the object is within this invalidation time.


You will also loose the object if you choose to remove it from the session or if you set a new object with the same name in that session.


If you want your object to be available to everyone, always, set it in the servletContext.


Hope it helps,

Joost

About | Sitemap | Contact