Logindemo.jsp
<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<form action="sucess.jsp" method="post" >
<table border="15" bgcolor="gray">
<tr>
<td>First Name:
<input type="text" name="fname" size="40" maxlength="40" >
</td>
</tr>
<tr>
<td>Last Name:
<input type="text" name="lname" size="40" maxlength="40" ><br>
<center>
<input type="Submit" Value="submit" >
<input type="Reset" Value="reset" >
</center>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
success.jsp
<%@ page language="java" import="javaBeandemo.LoginBean.*,java.io.*" 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<center>
<jsp:useBean id="LoginBean" class="javaBeandemo.LoginBean" scope="request"></jsp:useBean>
<jsp:setProperty name="LoginBean" property="*"/>
<%
if(LoginBean.isValidUser())
{
%>
Login Successful!<br>
Welcome!
<%
}
else
{
%>
User Not Found <br><br>
<a href="Beanloginpage.jsp">Try Again</a>
<%
}
%>
</center>
</body>
</html>
LoginBean
public class LoginBean {
private String Firstname="";
private String Lastname="";
public LoginBean()
{
}
public String getFirstname()
{
return Firstname;
}
public void setFirstname(String Firstname)
{
this.Firstname=Firstname;
}
public String getLastname()
{
return Lastname;
}
public void setgetLastname(String getLastname)
{
this.Lastname=Lastname;
}
public boolean isValidUser()
{
if(Firstname.equals(Lastname))// && Lastname.equals("raj"))
{
System.out.println("login success");
}else
{
System.out.println("login failed");
}
return true;
}
}


LinkBack URL
About LinkBacks






Reply With Quote