Search code examples
jspservletswebsphereservlet-filters

Can't read j_username after failed login


I use websphere jee form authentication, and I want to return the entered j_username in the error page.

I used a custom filter to intercept the call to j_security_check and added the j_username parameter to the request as an attribute, but when checking the attribute in the error page or in the controller I found it's always null. The parameter j_username was found in the filter before accessing j_security_check, the problem is after failed login attemp.

Why websphere when redirecting to the error url doesn't pass j_username and j_password, and how can I access j_username in the login error page?


Solution

  • The solution was simple. I found that websphere 8.5 creates a session when the action is /j_security_check. So, I used a web filter for /j_security_check to store j_username parameter in that session, and when login failure happens, I retrieved the username from that session using ${sessionScope[STORED_USERNAME]}.

    Hope that help