wood burning stoves 2.0*
The moose likes Servlets and the fly likes session.setAttribute vs request.setAttribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session.setAttribute vs request.setAttribute" Watch "session.setAttribute vs request.setAttribute" New topic
Author

session.setAttribute vs request.setAttribute

Nelson Nadal
Ranch Hand

Joined: Jun 06, 2002
Posts: 169
Just a clarification :-). Im just confuzed what and to when to use those 2 the same method.....
Correct me if Im wrong...
They have the same objective (to keep a certain value)but the difference is the scope of their attribute values? Am I right? I Thanks.
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
The basic difference between these 2 methods is the scope or lifetime of the attribute you are setting.
If you set an attribute on the request it is only available for that specific request. If you set it on the session it is available for that request and all subsequent requests by the user using the session (i.e. until the session expires or you explicitly remove the attribute)


Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
 
 
subject: session.setAttribute vs request.setAttribute
 
Similar Threads
Another Runtime Problem
Serialisation problem
Problem with ArrayList .contains() method
Jr. Java Programmer jobs (1-3 yrs. exp), Pittsburgh
declaring variables