I created a simple login page in which the user will provide a username and password, and then it will be saved in the session. After clicking the "Submit" button, it will display a welcome user or name. And if the user waits a few seconds, the session will expire and he will automatically return to the login page.
Here is my login page
<%@ page import="java.io.*,java.util.*" language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <jsp:useBean id="user" class="user.LoginUser" scope="session"></jsp:useBean> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>login</title> </head> <body> <h1><center>Give your login details</center></h1> <form method="post" action="check.jsp"> Username:<input type="text" name="username" size="20" value="<%=user.getUser() %>" > <br> Password:<input type="password" name="password" size="20" value=<%=user.getPassword() %> ><br> <input type="submit"> </form> </body> </html>
now in check.jsp i do my control part for username and password
<%@ page import="java.io.*,java.util.*" language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <jsp:useBean id="user" class="user.LoginUser" scope="session"></jsp:useBean> <jsp:setProperty name="user" property="*"/> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>login checking</title> </head> <body> <% String USER=user.getUsername(); int PASSWORD=user.getPassword(); if(USER.equals("abhirup")) { if(PASSWORD==54321) { pageContext.forward("display.jsp"); } else { out.println("Wrong password"); pageContext.include("login.jsp"); } pageContext.include("login.jsp"); } %> </body> </html>
and then finally i show it in display.jsp
<%@ page import="java.io.*,java.util.*" page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <jsp:useBean id="user" class="user.LoginUser" scope="session" ></jsp:useBean> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Display</title> </head> <body> <% String title="Welcome : successful login"; out.println(title);%> <h3><center>Your Name:Abhirup Parui</center></h3><br> Username<%=user.getUsername()%><br> <%session.setMaxInactiveInterval(20); pageContext.include("login.jsp"); %> </body> </html>
and also this is my LoginUser.java file
package user; public class LoginUser { String username; int password; public void setUsername(String value) { username=value; } public void setPassword(int value) { password=value; } public String getUsername(){return username;} public int getPassword(){return password;} }
I am using the Eclipse IDE and the Tomcat server. Eclipse did not show a single error on any page, but still, when I launched my login.jsp page.
I get this error when starting login.jsp
I followed this link
please help me find my mistakes.
Update
I can successfully launch my login page. I am getting this error now, but cannot figure out where the error is. the last part of the error is
how to fix this error. help