When to use session scope1?How session object is managed by the webcontainer?When the session object is created and when it is removed?

Showing Answers 1 - 6 of 6 Answers

sureshkumar

  • Nov 8th, 2006
 

hiSession is a unique object created by the server to the client.Session can be identified by using a session id.When the data is specific to a client at that time we need to store the data in session scope.Sessions can be managed in 2 ways1.Session id can be stored as a cookie and passing its value as a query string to the brower.2.When the cookies are disabled we will use an alternative procedure called URLRewriing.In this the session id is added to the url .By using response.encodeURL() we can implement URLRewriting technique.Regardssuresh

  Was this answer useful?  Yes

when the servlets has to use any  java object that is specific to the client for processing muiltiple requests  then we must store the java object in session object.
session objects are managed by the web container the following two techniqes.
1)using cookes       2) using  URL-rewriting techniqe.
Session id can be stored as a cookie and passing its value to the brower..When the cookies are dinied. we will use an alternative procedure called URLRewriing.In this the session id is added to the url .By using response.encodeURL() we can implement URLRewriting technique.
HttpSession session = request.getSeesion(true)-->the webcontainer creates a new session object when there is no session object on behalf of the browser that has sent to the request.If the session object is already avilable the container returns the existing session object.
HttpSession session = request.get.Session(false)-->the container returns null if there is no session object for the client that has sent request.If the session object is already avilable the container returns the existing session object.
the session object is removed... whenever the cookies are denied , session.invalidate()method is called.and depend on the session teme out  set by the container.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions