Learn about the Session Management Technique in Servlet i.e Hidden Form Field. Before discussing this technique in detail let’s first understand about Hidden Form Field. In this tutorial, you will get acquainted with details such as Syntax for Hidden Form Field, its Advantages, Disadvantages, and Example Program Using Hidden Form Field in Servlet.
- What is a Hidden Form Field?
- Advantages of Hidden Form Field
- Disadvantages of the Hidden Form Field
- Hidden Form Field Example
Hidden Form Field is a technique used to support Session Tracking. The name itself implies, these are fields added to an HTML form and are not displayed in the client browser. They are sent back to the server when the form that contains them is submitted. You include Hidden Form Fields like this.
<input name="username" type="hidden" value="btechgeeks" />
In other words, hidden form defines constant variables for a form. To a servlet receiving a submitted form, there is no difference between a hidden field and a visible field. Using hidden fields, we can rewrite our shopping cart servlets so that users can shop anonymously until checkout time.
Hidden fields are supported in all popular browsers, they demand no special server requirement, and they can be used with the client that hasn’t registered or logged in.
One drawback of this technique, is that the session persists only through a sequence of dynamically generated forms. The session cannot be maintained with the static document, emailed documents, bookmarked documents, or browser shutdown.
Read More Techniques of Session Management in Servlet
- Session Management in Servlet Using HttpSession
- Session Management Using URL Rewriting in Servlet
- Cookies Class in Servlet Explained with Example
In this example, we are storing username and password in a hidden text field and getting this information in another servlet.