Following is an example to understand the form concept.
Index.html
[html]<html>
<body bgcolor="skyblue">
<form action="formValidation.jsp" method="GET">
<center>
<h1>Register to the SPLessons</h1>
<img src="E:/splessons.png"></br></br>
First Name: <input type="text" name="first_name"></br></br>
Last Name: <input type="text" name="last_name" /></br></br>
<input type="submit" value="Submit" /></center>
</form>
</body>
</html>[/html]
Here the developer created the two text box fields to enter the
First Name,
Last Name and also created
submit button. When compile the code, page will be displayed as static.
JSP Forms - The
GET method is the default method to pass data from client to web server and it delivers a long string that shows up in the browser's Location. Never utilize the GET method in the event that you have secret key or other touchy data to go to the server. The GET method has size constraint: just 1024 characters can be in a solicitation string.
JSP Forms - A for the most part more solid method for passing data to a backend code is the
POST method. This method bundles the data in the very same route as GET strategies, yet as opposed to sending it as a content string after a ? in the URL it sends it as a different message. This message goes to the backend program as the standard information which one can parse and use for preparing.
formvalidation.jsp
[html]<html>
<body bgcolor="skyblue">
<center>
<h1>Welcome to the Splessons</h1></br></br>
<b>First Name:</b><%= request.getParameter("first_name")%><br/>
<b>Last Name:</b><%= request.getParameter("last_name")%></br></br>
Visit <a href="http://www.splessons.com/">splesson.com</a></center>
</body>
</html>[/html]
request.getparameter() is used to get the
First Name and
Last Name.
Output
When compile the program following is the output will be displayed where enter the details.
When click on submit button following output will be displayed.