Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
 
 
Search All Tutorials

 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 
JSP
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Post Method of the Form In JSP

                         

This section provides you the best illustration of the post method of the form in JSP. The HTTP post method sends data to the server from the HTML form elements. This method does not show the value of elements of the HTML form in the query string in url. This method keeps all the data value of the HTML elements secure and safe because of not showing those in anywhere.

In this section, you will see that the following JSP program creates a form with a text box for your name field. If you click on the submit button, JSP code checks for fulfill your name field and after satisfying, it will show the entered name with the message like "Your username is: chandan." because here the username you have entered the "chandan".

There is no need to use POST method in the form. This method doesn't append the URL. This method is mostly used for the working with some sensitive data like the password regarding the username or any type of secret numbers such as credit card number. If you want to pass as parameters, POST method prevents these type of secret numbers because this method doesn't show any parameter's value in the url of the browser.

Here is the JSP code of the example:

<html>
	<head><title>Using Post Method in JSP Form.</title></head>
	<body>
		<form method="post">
			<table border="0" cellpadding="0" 
cellspacing="0">
				<tr>
					<td>Enter your name:
 </td>
					<td><input type="text"
 size="20" name="txtName" /></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" 
name="B1" value="Submit" /><input type="reset" name="B2" value=
"Reset" /></td>
				</tr>
			</table>
		</form>
		<%
			if(request.getParameter("txtName")
 != null){
				if(request.getParameter("txtName").
equals(""))
					out.println("<html><font 
color=red>Please enter your name.</font></html>");
				else
					out.println("Your username 
is: " + request.getParameter("txtName"));
			}
		%>
	</body>
</html>

Output for the above page:

Image after submission the form:

Download UsingPostMethod.jsp file.

                         

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

4 comments so far (post your own) View All Comments Latest 10 Comments:

your code helped me very much

Posted by James on Tuesday, 08.21.07 @ 14:53pm | #23839

Hi,

This is site very to learn the J2EE technologies. But in the above example, description (Second Paragraph) about example is totally different from the code and sample screens.

Thanks
KCS

Posted by KCS on Monday, 08.6.07 @ 14:37pm | #22757

A very brilliant code to studyu

Posted by nilesh on Saturday, 02.24.07 @ 13:58pm | #9438

Your example was very helpful, and simple compared to servlets and JavaBeans.

Thanks :)

Posted by New_to_JSP on Monday, 02.5.07 @ 07:05am | #6073

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

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.

Hot Web Programming Job

Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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

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

Copyright © 2007. All rights reserved.