Session Management using Hidden Field in JSP

Program 1

<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        
    </body>
</html>

Program 2

<%@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="TestHidden1.jsp">
        
         <table>
             <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 3

<%-- 
    Document   : TestHidden1
    Created on : Dec 2, 2023, 1:22:16 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);
             
         %>
         <form method="post" action="TestHidden2.jsp">
             <input type="hidden" name="txtuser" value=<%=user%>>
             <input type="hidden" name="txtpass" value=<%=pass%>>
             <input type="Submit" value="Submit">
         </form>
        </center> 
    </body>
</html>

Program 4

<%-- 
    Document   : TestHidden2
    Created on : Dec 2, 2023, 1:27:06 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>
        <h1>Hello World This is Test 2 Page!</h1>
        <% 
        
          String user,pass;   
             user=request.getParameter("txtuser");
             pass=request.getParameter("txtpass");
            // out.println("User Name: "+user);
            // out.println("Password: "+pass);
         %>
          <form method="post" action="TestHidden3.jsp">
             <input type="hidden" name="txtuser" value=<%=user%>>
             <input type="hidden" name="txtpass" value=<%=pass%>>
             <input type="Submit" value="Submit">
         </form>
       </center>
    </body>
</html>

Program 5

<%-- 
    Document   : TestHidden3
    Created on : Dec 2, 2023, 1:30:19 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>
        <h1>Hello World This is Test 3 Page!</h1>
        <% 
        
          String user,pass;   
             user=request.getParameter("txtuser");
             pass=request.getParameter("txtpass");
             out.println("User Name: "+user);
             out.println("Password: "+pass);
         %>
         </center>
    </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 *