• 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

difference b/t session.setAttribute and request.setAttriute

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am reading a MVC model web application ,in which somewhere they are using request.setAttribute and somewhere session.setAttribute,as far as i understand when you've to dispatch a request to another JSP,use request.setAttribute whereas in a class that is doing various operations like,loading data or saving data session.setAttribute is required?If not then whats the difference b/w two?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The major difference is in the lifetime of the two contexts. Since the request only "lives" for the duration of a single request/response cycle, any scoped variables placed onto that request will go out of scope when the response is sent to the client.

Session context, on the other hand, sticks around over multiple requests made from the same client.
reply
    Bookmark Topic Watch Topic
  • New Topic