This is a very simple example in which we are going to
display the name on the browser which we have entered from the Html page.
To get the desired result firstly we have to make one
html form which will have only one field named as name in which we will enter
the name. And we will also have one submit button, on pressing the submit button
the request will go to the server and the result will be displayed to us.
In the servlet which will work as a controller here
picks the value from the html page by using the method getParameter().
The output will be displayed to you by the object of the PrintWriter
The code of the program is given below:
<title>New Page 1</title>
<p>Please enter your username and password</p>
<form method="GET" action="/htmlform/LoginServlet">
<p> Username <input type="text" name="username" size="20"></p>
<p> Password <input type="text" name="password" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
Frackson Hector LUBINGU
December 29, 2011
Hi. Have you got these tutorials in PDF format or in book format?? Let me know
May 13, 2014
That's a great example of using HTTP GET for form submission, but your particular example now includes a plaintext password in the URL, which is easily sniffable by every node between the client and the server, and which is also persisted in the server's logs. It is not advised to use this example for anything involving passwords. :-)