In this Section, We will discuss about tracking user's session using Hidden form field.

Tracking User's Session using Hidden Form Fields

In this Section, We will discuss about tracking user's session using Hidden
form field.

Hidden Form Field is used to maintain the session. It is one of the method to
handle sessions in JSP & servlet coding.

Syntax :

<input type ="hidden" name = "name" value="ABC">

This means that when we submit the values of the form, the name & value will
be included in the GET/POST method .In this session ID information would be
embedded within the form as a hidden field and submitted with the http post
command. In this session ID information would be embedded within the form as a
hidden field and submitted with the http post command.

Example :

In this Code, we have included a hidden field named as "hiddenfield" , which
will be retrieved & displayed by the "getHiddenformfield.jsp".

hiddenFormField.html

<

HTML>

<HEAD>

<TITLE>Hidden
Fields</TITLE>

</HEAD>

<BODY>

<H3>Included
Hidden fields with this Form </H3>

<FORMACTION="getHiddenformfield.jsp"METHOD="post">

<fontsize="4"color="red">

Enter your name :

<br><inputtype ="text"name =
"name"value =
"">

<inputtype="hidden"name="hiddenfield"value="Code
Name of Jdk 1.6 is Mustang ">

<inputtype="submit"value="submit">

</font>

</FORM>

</BODY>

</

HTML>

getHiddenformfield.jsp

<

HTML>

<

HEAD>

<

TITLE>The
Hiddern Fields</TITLE>

</

HEAD>

<

BODY>

<

h2><fontcolor="red">
HELLO !!!

<%

out.println(request.getParameter("name"));%>

</

font></h2>

<

h1><fontcolor="blue">

The hidden text is:

</

font></h1>

<

h2><fontcolor="purple">

<%

out.println(request.getParameter("hiddenfield"));
%>

</

font></h2>

</

BODY>

</

HTML>

OUTPUT :

After Submitting Value , the Next Page which displays "hidden field
" is :