0
We are using a form based authentication and below is the snippet from web.xml 

 <login-config>
  <auth-method> FORM </auth-method>
  <form-login-config>
        <form-login-page>/login.jsp?fromIndex=true</form-login-page>
        <form-error-page>/login.jsp?fromIndex=true&ldapAuth=fail</form-error-page>
    </form-login-config>
 </login-config>

And i do have a loginfilter that processes the authentication. So if the authentication fails i also want to send a error code to jsp to display error message. Since the HttpRequest is not carried over to the JSP page when authentication fails i cannot send the variable by putting in http request .

is there a alternate way to pass a variable to the login-errore jsp page ?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
user2600752
  • 63
  • 1
  • 6
  • So you want to pass a certain data from your Login filter to your application JSP, isn't it? But why do you say that "the HttpRequest is not carried over to the JSP"? – Little Santi Jun 15 '17 at 12:45
  • Yes, in the filter class i add a parameter into request. But What i think is when the authentication fails it would try to go to form error page, it would try to render that as new http request. Why i am saying this I am not able to get the parameter from the request in the error JSP – user2600752 Jun 15 '17 at 14:40
  • You can add attribute to session or request if authentication fails. And then read that attribute in your JSP page from HttpServletRequest or HttpSession JSP implicit objects. – fg78nc Jun 15 '17 at 15:32

1 Answers1

0

Instead through a parameter, you should put your data in the HttpRequest through an attribute:

// In the filter:
request.setAttribute("name", new MyObject());

// In the JSP:
MyObject obj=(MyObject)request.getAttribute("name");
Little Santi
  • 8,563
  • 2
  • 18
  • 46