tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: Reg form based authentication
Date Sat, 01 Oct 2005 14:55:29 GMT
sree kanth wrote:
> Hi all,
> i have been developing on JSP's for the last one year,but still i have never
> implemented form based authentication.
> Can any one help me in implenting form based authentication?
> Thank you all
> Sreekanth

Very basic example:
Put login.jsp and error.jsp in the root of your application and add 
the web.xml snippet to your application's web.xml file.

Mark

login.jsp
<html>
   <head>
     <title>Login</title>
   </head>
   <body>
     <form method="POST" action='<%= 
response.encodeURL("j_security_check") %>' name="loginForm">
       <input type="text" name="j_username" size="16" id="username"/>
       <input type="password" name="j_password" size="16" id="password"/>
       <input type="submit" value="Submit" />
       <input type="reset" value="Reset" />
     </form>
   </body>
</html>

error.jsp
<html>
   <head>
     <title>Login Error</title>
   </head>
   <body>
     <p>Login failed.</p>
   </body>
</html>

web.xml snippet
   <login-config>
     <auth-method>FORM</auth-method>
     <realm-name>Test</realm-name>
     <form-login-config>
       <form-login-page>/login.jsp</form-login-page>
       <form-error-page>/error.jsp</form-error-page>
     </form-login-config>
   </login-config>



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message