Saturday 1 September 2012

How to send data one jsp page to another jsp page


Index.jsp


<%--
    Document   : index
    Created on : 21 Aug, 2012, 11:53:21 PM
    Author     : Himanshu
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
           <form action="sucess.jsp" method="get">
              Name :  <input type="text" name="name"><br>
            Age :  <input type="text" name="age"><br>
             Dob :   <input type="text" name="dob"><br>
                <input type="submit">

            </form>

        </table>
    </body>
</html>

sucess.jsp
<%--
    Document   : sucess
    Created on : 22 Aug, 2012, 12:35:55 AM
    Author     : Himanshu
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <% String name=request.getParameter("name");%>
        <h1>Name : <%=name%></h1>
         <% String age=request.getParameter("age");%>
        <h1>Name : <%=age%></h1>
         <% String dob=request.getParameter("dob");%>
        <h1>Name : <%=dob%></h1>

    </body>
</html>

No comments:

Post a Comment