JSP Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 2579 Page Views: 

What approaches are used for Session Management in JSP ?



Posted By: Avi Date: 17 September 2009 06:24:36 AM
 Answer:

Following approches can be used for Session Management in JSP:

1) Cookies:
Cookies are small text files that a web server sends to a browser and that browsers returns the cookie when it visits the same site again. In cookie the information is stored in the form of a name, value pair.

2) URL Rewriting:
In URL rewriting we append some extra information on the end of each URL that identifies the session. This URL rewriting can be used with the clients where cookie is disabled. It is a good practice to use URL rewriting. In this session ID information is embedded in the URL, which is recieved by the application through Http GET requests when the client clicks on the links embedded with a page.

3) Hidden form fields:
In hidden form fields are html "input" control with type="hidden". The data stored in these fields are included in get or post method, but this information will not be displyed in the page. In this session ID information would be embedded within the form as a hidden field and submitted with the Http POST method.

4) HttpSession object:
javax.servlet.http.HttpSession is an interface that provides a way to identify a user across more than one page request or visit to a web site and maintains session data in the site.


Posted By: eTechPlanet


Date: 17 September 2009 06:24:36 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image ODsdiI
Related Questions
JSP : How deleting a cookie?    

How deleting a cookie?    

Cookie c = new Cookie ("name", null); c.setMaxAge(0); response.addCookie(killCookie);
Category: JSP Date: 11/4/2010 11:31:57 PM
JSP : How you can perform browser redirection?

How you can perform browser redirection?

By using the method sendRedirect of HttpServletResponse or forward method of RequestDispatcher.
Category: JSP Date: 11/4/2010 8:03:57 PM
JSP : How can the output of JSP or Servlet pages be prevented from being cached by the browser?

How can the output of JSP or Servlet pages be prevented from being cached by the browser?

We set the HTTP header attributes the following values: <% response.setHeader("Cache-Control....
Category: JSP Date: 11/4/2010 5:09:57 PM
JSP : Can you stop JSP execution in the middle of processing a request?

Can you stop JSP execution in the middle of processing a request?

Yes, by using the return statement to stop the processing of JSP. Where JSP is compiled to servlet a....
Category: JSP Date: 11/4/2010 2:47:57 PM
JSP : What is the difference between ServletContext and PageContext?

What is the difference between ServletContext and PageContext?

ServletContext gives the information about the container and PageContext gives the information about....
Category: JSP Date: 11/4/2010 2:14:57 PM