Followers

JSP: Session tracking using URLRewriting

index.html
==========

<form action="first.jsp" >
Name:<input type="text" name="userName"/><br/>

<input type="submit" value="submit"/>
</form>


first.jsp
=========

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        String n=request.getParameter("userName");
        out.print("Welcome "+n);

        out.println("<br /><br />");
        out.print("<a href='second.jsp?uname="+n+"'>Please click here for your details</a>");
                 
        out.close();
    %>
    </body>
</html>




second.jsp
===========

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%      
    //getting value from the query string
        String n=request.getParameter("uname");
        out.print("Hello "+n);

        out.close();
       
        %>
    </body>
</html>

No comments:

Post a Comment