Home Tutorial Java Jsp Tracking User's Session using Hidden Form Fields

 
 

Share on Google+Share on Google+
Tracking User's Session using Hidden Form Fields
Posted on: July 2, 2010 at 12:00 AM
Advertisement
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>

<FORM ACTION="getHiddenformfield.jsp" METHOD="post">

<font size="4" color="red">

Enter your name : <br><input type ="text" name = "name" value = "">

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

<input type="submit" value="submit">

</font>

</FORM>

</BODY>

</HTML>

getHiddenformfield.jsp 

<HTML>

<HEAD>

<TITLE>The Hiddern Fields</TITLE>

</HEAD>

<BODY>

<h2><font color="red"> HELLO !!!

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

</font></h2>

<h1><font color="blue">

The hidden text is:

</font></h1>

<h2><font color="purple">

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

</font></h2>

</BODY>

</HTML>

OUTPUT : 

 

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

Download Source Code 

Advertisement

Related Tags for Tracking User's Session using Hidden Form Fields:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 2, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com