Home » Archive

Articles tagged with: How to get/set values from servlet page to session object

Java Codes »

[12 Feb 2009 | One Comment | 2,283 views]
Java Servlet – How to get/set values from servlet page to session object

Applications like UserManagement, Shopping Cart etc require to store values in cache so that when a user returns his information is restored from cache.
There are three ways to implement sessions in Java Servlets:
* Cookies: HTTP Cookies to store information. Methods response.addCookie(cookie) will add cookie and request.getCookies() will return value of cookies.
* URL Rewriting: Append data on the end of each URL that identifies the session like http://localhost/yourservlet?session-id=value.
* Hidden form fields: HTML forms can have