Share on Google+Share on Google+

Hidden Form Fields

Hidden form field is used to maintain some of the data it can also be used maintain the session. It is one of the way to maintain the session.

Hidden Form Fields


Hidden form field is used to maintain the session. It is one of the way to maintain the session. In hidden form fields the html entry will be like this : <input type ="hidden" name = "name" value="">. This means that when you submit the form, the specified name and value will be get included in get or 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 program of hidden form fields firstly we are making a jsp form or html form in which we are using the post method and where the request will be submitted or controlled, it is done by a controller SettingHiddenField.jsp, it is the jsp where the business will be applied.  

The code of the program is given below:

        <TITLE>Submitting Hidden Fields</TITLE>
        <H1>How to use a Hidden fields </H1>
        <FORM ACTION="SettingHiddenField.jsp" METHOD="post">
			Enter your name : <input type ="text" name = "name" value = ""> 
            <input type="hidden" name="hidden" value="You are most Welcome!">
            <input type="submit" value="submit">


    <TITLE>Reading Hidden Controls</TITLE>
        <H1>Reading Hidden Controls</H1>
			String string = request.getParameter("name");
            String text = "";
            if(request.getParameter("text1") != null) {
                out.println(string + "The hidden 
text is:" +request.getParameter("text1")); 
                text = request.getParameter("text1");
        <FORM ACTION="GettinHiddenField.jsp" METHOD="post">
            <input type="text" name="text1">
            <input type="hidden" name="hidden" 
                value="<%= text%>">
            <input type="submit" value="Set Hidden Text">




    <TITLE>The Hiddern Fields</TITLE>




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

        <H1>We can read hidden fields</H1>

        The hidden text is: 

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



The output of the program is given below:

After adding the name the output will be.

Download this example.


Posted on: February 9, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.

Discuss: Hidden Form Fields   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
Mr Complimenter
February 12, 2012

Cool awesome nice good great
April 26, 2012
I am not getting this correctely

The same code i have been trying it but even after downloading it and use.... i could not get the solution.. please help..
Ambresh Kumar Pandey
April 27, 2012
Regarding hidden field

Hello I want to know the used of hidden field with the html controls.Please give the complete code and information on my Email Id. Thank You.