How to handle a form in JSP
This section teaches you about the creating a from and the procedure of handling the form through the JSP code. This section provides JSP code which used the HTML code for creating a form and this form is handled by the JSP code.
All the HTML code are the client side code i.e. executed on your browser while all the JSP code is the server side code which executes on the server.
Here is the code of the program:
<html> <head><title>Handling Form in JSP.</title></head> <body> <form method="post"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td>Enter your name: </td> <td><input type="text" name="txtName" size="20"/></td> </tr> <tr> <td> </td> <td><input type="submit" name="B1" value="Submit"/><input type="reset" name="B2" value="Reset"/></td> </tr> </table> </form> <% if(request.getParameter("txtName") != null){ out.println(request.getParameter("txtName")); } %> </body> </html>
Output of the program: