as i am new i refer tomcat 's jsp-example my structure of webapp webapps-| | saraf | index.html(which link to login.jsp) | protected | login.jsp,error.jsp,index.jsp.
my login.jsp <html> <head> <title>Login Page for Examples</title> <body bgcolor="white"> <form method="POST" action='<%= response.encodeURL("j_security_check") %>' > <table border="0" cellspacing="5"> <tr> <th align="right">Username:</th> <td align="left"><input type="text" name="j_username"></td> </tr> <tr> <th align="right">Password:</th> <td align="left"><input type="password" name="j_password"></td> </tr> <tr> <td align="right"><input type="submit" value="Log In"></td> <td align="left"><input type="reset"></td> </tr> </table> </form> </body> </html> ----------------- error.jsp ------------------ <html> <head> <title>Error Page For Examples</title> </head> <body bgcolor="white"> Invalid username and/or password, please try <a href='<%= response.encodeURL("login.jsp") %>'>again</a>. </body> </html> ---------- index.jsp <% if (request.getParameter("logoff") != null) { session.invalidate(); response.sendRedirect("index.jsp"); return; } %> <html> <head> <title>Protected Page for Examples</title> </head> <body bgcolor="white"> You are logged in as remote user <b><%= request.getRemoteUser() %></b> in session <b><%= session.getId() %></b><br><br> <br> If you have configured this app for form-based authentication, you can log off by clicking <a href='<%= response.encodeURL("index.jsp?logoff=true") %>'>here</a>. This should cause you to be returned to the logon page after the redirect that is performed. </body> </html>