Saturday, 4 April 2015

JSP_POST_METHOD_example

(1)write below code example for html form   save it  as hello.html  & save this file under path="C:\xampp\tomcat\webapps\ROOT" :

<html>
<body>
<form action="main.jsp" method="GET">
First Name: <input type="text" name="first_name">
<br />
Last Name: <input type="text" name="last_name" />
<input type="submit" value="Submit" />
</form>
</body>
</html>


(3)now use get method for collecting  form value  following code is for  main.jsp  :

<html>
<head>
<title>Using GET and POST Method to Read Form Data</title>
</head>
<body>
<center>
<h1>Using GET Method to Read Form Data</h1>
<ul>
<li><p><b>First Name:</b>
   <%= request.getParameter("first_name")%>
</p></li>
<li><p><b>Last  Name:</b>
   <%= request.getParameter("last_name")%>
</p></li>
</ul>
</body>
</html>


(4)now runt jsp file:

http://localhost:8080/form.html

No comments:

Post a Comment