JSP - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

JSP Forms

JSP Forms

shape Description

JSP Forms, Working with credential applications is always a challenging task, as earlier discussed JSP code will be combined with HTML code. While working with forms in any technology GET and POST methods will be used, many developers will prefer POST method why because it carries a large amount of data to the server where as GET method is the default method. Following is an example which describes how the form application will work.

shape Example

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.

Get Method

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.

Post Method

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.

Summary

shape Key Points

  • JSP Forms - request.getParameter is utlized to retrieve the data
  • JSP Forms - POST requests can not be book marked.
  • Get method is the default method.