Home > J2EE, JSP, Technical > Login Form in JSP

Login Form in JSP

February 28, 2012

LoginForm.jsp

—————————————————————————-

<html>
<head>
<title>Login Form</title>
<style type=”text/css”>
div {
margin: 250px,450px;
}
</style>
</head>
<body>
<form action=”LoginValidation.jsp” method=”post” align=center>
<div>
<table border=0>
<tr>
<td>
User Name:
</td>
<td>
<input type=”text” name=”user” />
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type=”password” name=”pass” />
</td>
</tr>
<tr>
<td colspan=2 align=right>
<input type=”submit” value=”Submit” >
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
LoginValidation.jsp

—————————————————————————-

<html>
<head>
<title> Login Validation </title>
</head>
<body>
<%
String userName = request.getParameter(“user”);
String passWord = request.getParameter(“pass”);
boolean valid = false;
if(userName.equals(“karu”) && passWord.equals(“karuvachi”))
valid=true;
if(valid == true)
{
%>
Congratulations, you can work on this application 🙂
<%
}
else
{
%>
Sorry, you cannot work on this application 😦
<%
}
%>
</body>
</html>

Advertisements
Categories: J2EE, JSP, Technical
%d bloggers like this: