• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Related to Session and Request objects

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We fetch the session object from the request object.
Then what is the difference between request and session?
Why cant I use the request itself instead of session?
Is it that session can be fetched from request object only? Or is there any other way to get the session object?
Somebody please explain.

Regards,
Sriram
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

yes, you are right session retrieval from request object. But you have to read about variable scope. The request and session are two different scope.

Request scope basically use for particular request. while session scope available through out web application. so which variable set as session scope you can access any part of request and therefor you have to access session scope form request object.

 
Sriram Sharma
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nishan,

I am still not able to get the complete picture.
I am unable to get the exact meaning of the statement "while session scope available through out web application. so which variable set as session scope you can access any part of request and therefor you have to access session scope form request object." :-(

Can somebody help me out in understanding the session and request scope and also about session and request objects?

Regards,
Sriram

 
Nishan Patel
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

while session scope available through out web application. so which variable set as session scope you can access any part of request and therefor you have to access session scope form request object



what I mean to say, when you set any variable using session you can you can use this variable at any place of your web application. That means at any request of your web application. Session available for you and for your web application at any time and at any place. While when you use request.setAttribute("user", "Nishan"); then that user variable available only that particular request. After that request if you use that user attribute that scope of user lost and you can not access that variable. While instead of if you use session then after second request that user object available for you..

 
Grow a forest with seedballs and this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic