Home Jsp Jspsession Hidden Form Fields
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Hidden Form Fields

Advertisement
Hidden form field is used to 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:

<HTML>
    <HEAD>
        <TITLE>Submitting Hidden Fields</TITLE>
    </HEAD>
 
          <BODY>
        <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">
        </FORM>
    </BODY>
</HTML>

 

<HTML>
  <HEAD>
    <TITLE>Reading Hidden Controls</TITLE>
  </HEAD>
          <BODY>
        <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">
        </FORM>
    </BODY>
</HTML>

 

<HTML>

  <HEAD>

    <TITLE>The Hiddern Fields</TITLE>

  </HEAD>

      

    <BODY>

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

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

        The hidden text is: 

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

    </BODY>

      </HTML>

The output of the program is given below:

After adding the name the output will be.

Download this example.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  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.

Posted on: February 9, 2008

Related Tutorials

Ask Questions?    Discuss: Hidden Form Fields   View All Comments

Post your Comment


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

Cool awesome nice good great
Ravi
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.
DMCA.com