You can simply make use of the code of the Session Handling in JSP from below:
Code:
<html>
<head>
<title>Session Jsp</title>
</head>
<body>
<form method = "post" action = "session.jsp">
<font size = 6>Name<input type = "text" name = "str"></font><br><br>
<font size = 6>Password<input type="password" name = "pwd" >
</font><br><br>
<input type = "submit" name = "submit" value = "submit" >
</form>
</body>
</html>
<%
String str = request.getParameter("str");
String pwd = request.getParameter("pwd");
if(str.equals("Williams") && pwd.equals("abcde"))
{
session.setAttribute("userstr",str);
response.sendRedirect("NextPageAfterFirst.jsp");
}
else
{
response.sendRedirect("SessionManagement.html");
}
%>
<html>
<head>
<title>Welcome in In the program of URL rewriting</title>
</head>
<body>
<font size = 6>Hello</font> <%= session.getAttribute("userstr") %>
</body>
</html>
Bookmarks