login page
<form method='post' action='j_security_check'>
<input type='text' name='j_username'>
<input type='password' name='j_password'>
</form>
content from web.xml
<web-app>
<security-constraint>
<web-resource-collection>
<web-resource-name>User Auth</web-resource-name>
<url-pattern>/auth/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>login.jsp</form-login-page>
<form-error-page>error.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
Form based authentication works fine. But if I access the index.jsp directly from http://localhost:8080/index.jsp/j_security_check?j_username=admin&j_password=admin is not working.
Why its not working ?
method='post'
but a browser send a GET request (well from what I know), If you really want to do that, you need to manage the GET request too. (but is it really necessary ? Use a redirect page if you really need that) – AxelH