When I specify a security login system via FORM within web.xml (Tomcat), is there a way to capture an Error or Exception through the informed form-error-page jsp using EL if the authentication isn’t succeed?
I’m asking this because I’m wondering to use the same JSP form specified within form-login-page to serve as the form-error-page jsp, thus the JSTL Core c:if would be useful to capture an eventual Exception through ${not empty pageContext.exception}.
Thanks.
Just check if it’s forwarding to itself (which thus implies that there’s an error) on postback. You can check that by checking if the
javax.servlet.forward.request_urirequest attribute (which indicates the request URI as the enduser sees in browser’s address bar) doesn’t end with/j_security_checkwhileHttpServletRequest#getMethod()equals toPOST.