• Post Reply Bookmark Topic Watch Topic
  • New Topic

session v/s request ...  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference b/w this two :

request.setAttribute("A",b);
session.setAttribute("A",b);

Thanks .
 
H Wilson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will want to add objects to the session for those things unique to each user that you need throughout the user's session. A shopping cart is the most obvious example. Add objects to the request for those things you will need only for a single request. I find that I add most objects either to the session or the application (servlet context), depending on whether or not they are unique to a user, but I suppose the request could also be useful in some instances.

I just can't say enough about "Head First Servlets and JSP." Everyone and his dog should own a copy. Of course, if your dog has not yet learned polymorphism, buy him a copy of Hostman and Cornell's Core Java, Vols. I and II.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!