POST request
Learn about the POST request and create a form to pass parameters to the web server.
In a GET request, parameters are passed as a query string in the URL. The routers and ISPs can see the parameters and read values as they are passed in a GET request. POST request is another type of HTTP request which is more secure. In this lesson, we will pass parameters through a form using a POST request. The POST request is not completely secure, but it is better than a GET request. Name of a player can be passed as part of the URL as well as part of the form. Now we will pass it through a form.
Creating a form
The first step is to create a form which will have fields for input parameters. We will create the form in welcome.jsp
. Forms can be created using the <form>
tag. We need to specify who will handle the information in the form. Since we want the PlayerServlet
to handle this request, we will specify player.do
as action
. In our application, any request to player.do
is handled by the PlayerServlet
:
<form action="/player.do">
</form>
Text box input element
Next, we will create an input element of text type and specify the name of the parameter.
Get hands-on with 1400+ tech skills courses.