Home Jsp Simple-jsp-example Multiple Forms in JSP
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Multiple Forms in JSP

Advertisement
The form tag creates a form for user input. A form can contain checkboxes, textfields, radio- buttons and many more. Forms are used to pass user- data to a specified URL which is specified in the action attribute of the form tag.

Multiple Forms in JSP

        

The form tag creates a form for user input. A form can contain checkboxes, textfields, radio- buttons and many more. Forms are used to pass user- data to a specified URL which is specified in the action attribute of the form tag. For the browser it is important to know where to send the request and how to send the request. To help the browser, form tag provides two attributes, first is action: Here is the address of the jsp page or any other page where the request will go. Second is the method, which tells which method is the browser using for sending the request. The methods are mainly the get and post.

 

The code of the program is given below:

 

 

<html>
  <head>
  <title>Using Multiple Forms</title>
  </head>
  <body>
  <h1>Using Multiple Forms</h1>
  <% 
  if(request.getParameter("button") != null) {
  %>
  You clicked 
  <%= request.getParameter("button") %>
  <%
  }
  %>
  <form name="form1" method="get">
  <input type="hidden" name="button" value="button 1">
  <input type="submit" value="Button 1">
  </form>
  <form name="form2" method="get">
  <input type="hidden" name="button" value="button 2">
  <input type="submit" value="Button 2">
  </form>
  <form name="form3" method="get">
  <input type="hidden" name="button" value="button 3">
  <input type="submit" value="Button 3">
  </form>
<form name="form4" method="get">
  <input type="hidden" name="button" value="button 4">
  <input type="submit" value="Button 4">
  </form>
<form name="form5" method="get">
  <input type="hidden" name="button" value="button 5">
  <input type="submit" value="Button 5">
  </form>
  </body>
</html>

The output of the program is given below:

The output of this form will be:

Download this example.

Advertisement

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: March 11, 2008

Related Tutorials

Ask Questions?    Discuss: Multiple Forms in JSP  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Pukri De Silva
September 27, 2011
Java

This is realy helpful.Wanna help to du it vth Spring MVC.
DMCA.com