Tuesday, 31 March 2015

JSP Demo (Form)

// This program asks user for information and displays them dynamically (Like filling a form) 

1>
After filling the form and clicking the submit button 
2>



1> Index.html

//This is the form page which will take the user input

<html>
    <head>
        <title>Jsp Assignment 1</title>
        
        
    </head>
    <body>
        <form action="Detail.jsp" method="post">
            <table>
<tr>
                    <td>Candidate Name :</td>
                    <td> <input name="txtName" placeholder="Name" type="text" /></td>
                </tr>
<tr>
                    <td>Highest Qualification: </td>
                    <td>
                        <select name="txtQual">
                        <option value="Phd"> PHD</option>
                        <option value="M.Tech"> M.Tech</option>
                        <option value="B.Tech">B.Tech</option>
                        <option value="Graduate">Graduate</option>

                        </select>
                    </td>
                </tr>
<tr>
                    <td> Percentage : </td>
                    <td><input name="txtPercent" placeholder="Percentage " type="text" /></td>
                </tr>
<tr>
                    <td>  Email Id : </td>
                    <td> <input name="txtEmail" placeholder=" Email Id " type="text" /></td>
                </tr>
<tr>
                    <td> Phone :</td>
                    <td>  <input name="txtPhone" placeholder="Phone " type="text" /></td>
                </tr>
<tr>
                    <td colspan="2"><input name="submit" type="submit" /></td>
                </tr>
</table>
</form>
</body>
</html>


2> Detail.jsp

//This page will print the input data by the user


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Details</title>
    </head>
        
    <table>
        <tr>
            <td><b>Candidate Name :</b></td>
            <td> <%=request.getParameter("txtName")%></td>
        </tr>
        
        <tr>
            <td> <b>Highest Qualification :</b></td>
            <td>  <%= request.getParameter("txtQual")%></td>
        </tr>
        
        <tr>
            <td><b>Percentage :</b></td>
            <td><%= request.getParameter("txtPercent")%></td>
        </tr>
        
        <tr>
            <td><b>Email Id :</b></td>
            <td> <%= request.getParameter("txtEmail")%></td>
        </tr>
        
        <tr>
            <td><b>Phone :</b></td>
            <td> <%= request.getParameter("txtPhone")%></td>
        </tr>
    </table>
       
    
</html>




No comments:

Post a Comment