Session Management using URL Rewriting in JSP

Program 1

<%-- 
    Document   : LoginPage
    Created on : Nov 30, 2023, 6:01:34 PM
    Author     : admin
--%>

<%@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>
          <center> 
              <form method="post" action="UrlSession1.jsp">
              <table border="1">
                  <tr>
                      <th>User Name</th>
                      <td><input type="text" name="txtuser"></td>
                  </tr>   
                 <tr>
                      <th>Password</th>
                      <td><input type="password" name="txtpass"></td>
                  </tr>    
                  <tr>
                     <td></td>
                     <td><input type="submit" value="Submit"></td> 
                  </tr>  
              </table>    
              </form>   
          </center>       
    </body>
</html>

Program 2

<%-- 
    Document   : UrlSession1
    Created on : Nov 30, 2023, 6:06:40 PM
    Author     : admin
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%!
    String user,pass;
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <center>
        <% 
               
               user=request.getParameter("txtuser");
               pass=request.getParameter("txtpass");
               out.println("User Name:" + user);
               out.println("Password:" + pass);
        %>
        
        <A href="UrlSession2.jsp?username=<%=user%>&password=<%=pass%>">click here for next page</A>
        </center>
    </body>
</html>

Program 3

<%-- 
    Document   : UrlSession2
    Created on : Nov 30, 2023, 6:10:41 PM
    Author     : admin
--%>

<%@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>
        <h1>Hello World! this is next page</h1>
        <center>
          <% 
            String user,pass;
            user=request.getParameter("username");
            pass=request.getParameter("password");
            out.println("USER NAME= " + user);
            out.println("PASSWORD= " + pass);
          
          %>            
         <A href="UrlSession3.jsp?username=<%=user%>&password=<%=pass%>&[email protected]">click here for next page</A>  
        </center>
    </body>
</html>

Program 4

<%-- 
    Document   : UrlSession3
    Created on : Nov 30, 2023, 6:21:30 PM
    Author     : admin
--%>

<%@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>
        <h1>Hello World! Url Session 3</h1>
       <% 
            String user,pass,mail;
            user=request.getParameter("username");
            pass=request.getParameter("password");
            mail=request.getParameter("email");
            out.println("USER NAME= " + user);
            out.println("PASSWORD= " + pass);
            out.println("EMAIL= " + mail);
       %> 
    </body>
</html>
courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

Leave a Reply

Your email address will not be published. Required fields are marked *