Xpode.com        Click here to Print this article.

Java/Servlets interview questions: -Explain differences between getSession(true) and getSession(false)?

Session's can be considered as a series of related interactions between client and the server that take place over a period of time. Because HTTP is a stateless protocol these series of interactions are difficult to track. That’s where we can use HttpSession object to save in between of these interactions so that server can co-relate between interactions between clients.

Figure: - Session code walkthrough

Above is the code snippet which displays session data. Step1 returns an HttpSession object from the request object. “true” parameter in the “getsession” function ensures that we get a session object if there is no current session object in request which ensures that we never get a null session object. In Step 2 we are using the “getattribute” function to return the session value. In step 3 we are setting the session value with “Name” key.

See the following video on Java which describes Hibernate and it concepts: -

Click for more Java/Servlets interview questions

Regards,

Visit for more author’s blog on Java/Servlets interview questions



http://
http://

Contributed by:
Shivprasad Koirala
We conduct training for Java/J2EE technologies like design patterns, J2EE, Struts, Hibernate, Spring, Rich Interface etc. and likes to write articles on the same in free time.

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=587

Click here to go on website