• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session v/s request ...

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference b/w this two :

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

Thanks .
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic