JSP Authentication Implementation | Javamazon
JSP Authentication Implementation | Javamazon:
'via Blog this'
'via Blog this'
In this example we will show you how to authenticate the user against user name and password. This program consists of a HTML Page, authenticate JSP page, LoginError JSP Page to authenticate the user against password.
HTML Form (main.html)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <html> <body> <form name= "f1" action= "authenticate.jsp" > <font size= 4 face= "Verdana" color=# 120292 > <marquee> Online Banking System </marquee> <br><br> <table cellspacing= 15 cellpadding= 15 bgcolor=# 959999 colspan= 2 rowspan= 2 align= "center" > <tr> <td> Bank Customer Authentication Form</td> </tr> <tr> <td>Enter Customer Id :</td> <td><input type=text name= "uname" ></td> </tr> <tr> <td>Enter Password: </td> <td><input type=password name= "password" ></td> </tr> </table> <br> <table align= "center" > <tr> <td><input type= "submit" value= " Login " ></td> <td><input type= "Reset" value= " Cancel " ></td> </tr> </table> </font> </form> </body> </html> |
1 |
LoginError JSP Page
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <%@ page isErrorPage= "true" %> <html> <body> <h3>An exception has occurred</h3> <table> <tr> <td>Exception Class:</td> <td><%= exception.getClass() %></td> </tr> <tr> <td>Message:</td> <td><%= exception.getMessage() %></td> </tr> </table> <br> To go to login page again, click Login Page button <form name= "f2" action= "main.html" > <input type= "submit" name= "button1" value= "Login Page" > </form> </body> </html> |
1 |
Authenticate JSP page
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <%@ page errorPage= "LoginErrorPage.jsp" %> <html> <body> <font face = "verdana" > <% String user=request.getParameter( "uname" ); int customerID=Integer.parseInt(user); String pass=request.getParameter( "password" ); if ( customerID== India143 && pass.equals( "Bangalore" )) { out.println( "Welcome to Online Banking System" ); %> <br><br> <% out.println( "Login Successful" ); } else { out.println( "Login Unsuccessful" ); } %> </font> </body> </html> |
Refer the other article Implement Redirect JSP
0 comments:
Post a Comment