2) Hidden Form Field
In case of Hidden Form Field a hidden (invisible) textfield is used for maintaining the state of an user.
In such case, we store the information in the hidden field and get it from another servlet. This approach is better if we have to submit form in all the pages and we don't want to depend on the browser.
Let's see the code to store value in hidden field.
Here, uname is the hidden field name and Vimal Jaiswal is the hidden field value.
Real application of hidden form field
It is widely used in comment form of a website. In such case, we store page id or page name in the hidden field so that each page can be uniquely identified.
Advantage of Hidden Form Field
Disadvantage of Hidden Form Field:
Example of using Hidden Form Field
In this example, we are storing the name of the user in a hidden textfield and getting that value from another servlet.
download this example (developed using Myeclipse IDE)
download this example (developed using Eclipse IDE)
download this example (developed using Netbeans IDE)