Servlet Tutorial

Handling Client Request form data

Handling Client Request form data:

  • Whenever we want to send an input to a servlet that input must be passed through html form.
  • An html form is nothing but various controls are inherited to develop an application.
  • Every form will accept client data end it must send to a servlet which resides in server side.
  • Since html is a static language which cannot validate the client data. Hence, in real time applications client data will be accepted with the help of html tags by developing form and every form must call a servlet.

Steps for DEVELOPING a FORM:

  1. Use <form>...</form> tag.
  2. To develop various controls through <input>...</input> tag and all <input> tag must be enclosed with in <form>...</form> tag.
  3. Every form must call a servlet by using the following:
  4. <form name="name of the form" action="either absolute or relative address" method="get or post">
    .........
    .........
    </form>
    

Write an html program to develop the a form:

form developing

Answer:

<html>
    <title>About Personal Data</title>
    <head><center><h3>Personal Information</h3></center></head>
    <body bgcolor="#D8BFD8">
        <form name="persdata" action="./DataSer">
            <center>
                <table bgcolor="#D2B48C" border="1">
                    <tr>
                        <th>Enter ur name : </th>
                        <td><input type="submit" name="persdata_eurn" value=""></td>
                    </tr>
                    <tr>
                        <th>Enter ur course : </th>
                        <td><input type="text" name="persdata_eurc" value=""></td>
                    </tr>
                    <tr>
                        <td align="center"><input type="button" name="persdata_send" value="Send"></td>
                        <td align="center"><input type="reset" name="persdata_clear" value="Clear"></td>
                    </tr>
                </table>
            </center>
        </form>
    </body>
</html>