Sunday, July 9, 2017

5. a. Write a JAVA JSP Program to implement verification of a particular user login and display a Welcome page.

login.jsp

<html>
<head> <title> Login page </title>
</head>
<body>
<form action="validation.jsp">
<table border="0">
<tr>
<td> USER ID: </td>
<td>
<input type="text" name="uname" /> <br>
</td>
</tr>
<tr>
<td> PASSWORD: </td>
<td>
<input type="password" name="password" /> <br>
</td>
</tr>
<tr> <td align ="center">
<input type="submit" value="submit" >
<input type="reset" value="reset">
</td>
</tr>
</form>
</body>
</html>

validation.jsp

<html>
<body>
<%! String uid="student"; %>
<%! String pass="aitmca"; %>
<%! String id, password; %>
<% id=request.getParameter("uname"); %>
<% password=request.getParameter("password"); %>
<% if(uid.equals(id)&&pass.equals(password))
{
%>
<jsp:forward page="welcome.jsp"/>
<%
}
else
%>
<jsp:forward page="error.jsp" />
<%
}
%>
</body>
</html>

welcome.jsp


<html>
<body bgcolor="pink">
<center>
<%! String id; %>
<% id=request.getParameter("uname"); %>
<h1> welcome <%=id%> to the home page </h1>
</center>
</body>
</html>

error.jsp

<html>
<head> <title>JSP Page</title> </head>
<body bgcolor="pink">
<h1>INVALID ENTRY</h1>
</body>
</html>

4 comments: