Java Reference
In-Depth Information
F IGURE 5.1
Output of HiddenFieldServlet.
You can see that hidden form fields have their advantages. They are easy to implement and are
supported by most browsers. This technique also has its disadvantages. The hidden fields must
be created in a particular sequence. You are not able to click the Back button on your browser
without losing the additional fields added to the current page. You are also restricted to dynam-
ically generated documents.
Working with Cookies
One of the more elegant solutions to session tracking is the use of persistent cookies. Netscape
first introduced cookies in one of the company's first versions of Netscape Navigator.
A cookie is a keyed piece of data that is created by the server and stored by the client browser.
Browsers maintain their own list of unique cookies. This makes cookies a very viable solution
for session tracking.
The Servlet API provides built-in support for cookies. It does this through the use of the
Cookie class and the HttpServletResponse.addCookie() and
HttpServletRequest.getCookies() methods.
Search WWH ::




Custom Search