Showing posts with label Session. Show all posts
Showing posts with label Session. Show all posts

Friday, 20 April 2012

Java/Servlets interview questions: -Mention 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

Tuesday, 15 November 2011

Java/servlets interview questions: - Session tracking and methods for session tracking.

This is one of the asked Java/J2EE interview questions during an interview. So one can start proceeding with the answer as follows.

Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time

Following are the methods for session tracking: -
  • User Authentication - occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password.
  • Hidden form fields - fields are added to a HTML form which is not displayed in the client’s browser. When the form containing the fields is submitted, the fields are    sent back to the server.
  • URL rewriting - every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change.
  • Cookies - a bit of information that is sent by a web server to a browser and which can later be read back from that browser.
  • HttpSession- places a limit on the number of sessions that can exist in memory.

See the following video on Value List Handler as follows: -



Click and get to see more on  Java/J2EE interview questions series.

Regards,

Also visit author’s blog for more Java/J2EE interview questions