Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
POST METHOD 
 

In this example we are going to show how we can make use of the POST in the JSP. After going through this example you will better understand the concept of the POST. Post is mainly used to send the data to the server and to retrieve the data from the serv

 

POST METHOD

                         

In this example we are going to show how we can make use of the POST in the JSP. After going through this example you will better understand the concept of the POST. Post is mainly used to send the data to the server and to retrieve the data from the server. In POST the data will not get appended in the URL but sent across with the body of the content. 

Firstly in this example we are going to make one jsp form which will some textfields and a submit button. The user will fill up the form and the request will be submitted to the controller which will perform rest of the task and gives back the response. 

This form contains some textfield like name, password, one radio button that is of sex, one checkbox, one option button and a submit button. The user has to fill up the form and as soon as the user fills the form and clicks a submit button the request goes to the controller. The path of the controller is given in the form attribute action and the method which will be used to send the data to server is post which is defined in the form attribute method.

As soon as the controller gets the request it matches all the parameters we have passed in the form and the result is displayed to the user.

Code of the indexPostForm.html.txt file:

<html>
<head><title>JSP Form Post Example</title></head>
<body>
<center><table border="2">
<tr>
<td>JSP Form Post Example</td>
</tr>
<td>
</center></table>
<center><table border="2">
<form action="nextPageToPost.jsp" action="post">
<center><table border="2">
<tr>
<td align="center"colspan="2"><h4>
Enter data for post to next page <h4></td>
</tr>
<tr>
<td>Enter your name</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Enter your password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td><b>Sex</b></td>
<td><input type="radio" name="sex" value="Male">Male</td>
<td><input type="radio" name="sex" value="Female">Female</td>
</tr>
<tr>
<td>Are you regular visitor of RoseIndia.net</td>
<td><input type="checkbox" name="check"></td>
</tr>
<tr>
<td>Nationality</td>
<td><select name="nationality" size="1">
<option>India</option>
<option>USA</option>
<option>UK</option>
<option>SRI LANKA</option>
</td>
</tr>
<tr>
<td>Description</td>
</tr>
<tr>
<td><textarea rows="2" name="description" cols="20">
</textarea></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="submit"></td>
<td><input type="reset" name="reset" value="reset"></td>
</tr>
</form>
</table>	
</center>
</body>
</html>

Code of the nextPageToPost.jsp file:

<html>
<head><title>JSP Form Post Example</title></head>

<body>
<center><table border="2">
<tr>
<td><h3>Your message has been posted by using Post Method</h3></td> 
</tr>
</center></table>
<center><table border="2" >
<tr>
<td><h4>Name:</h4></td><td><%=request.getParameter("name") %></td> 
</tr>
<tr>
<td><h4>Password:</h4></td><td><%=request.getParameter("name") %></td> 
</tr>
<tr>
<td><h4>Sex:</h4></td><td><%=request.getParameter("sex")%></td> 
</tr>
<tr>
<td><h4>Are you regular <br>visitor of RoseIndia.ne</h4></td><td>
<% if(request.getParameter("check").equals("on"))out.println("Yes"); %></td> 
</tr>
<tr>
<td><h4>Nationality</h4></td><td><%=request.getParameter("nationality") %>
</td> 
</tr>
<tr>
<td><h4>Description</h4></td><td><%=request.getParameter("description") %>
</td> 
</tr>

</center></table>

</body>
</html>

The output of the program is given below:

Download nextPageToPost.jsp file.

Download indexPostForm..html file.

                         

» View all related tutorials
Related Tags: c client request display page name cli ie ref e li spl m nt play isp cl es age me

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.