Search code examples
javasecurityjbossjaas

How to show error Message in the login page when using JAAS instead of redirection to error page


i successfully secured my web application using JAAS to do that i followed the tutorial on this page http://www.thejavageek.com/2013/09/18/configure-jaas-jboss-7-1-mysql/ but the problem is that you need to define a specific page to handle the case when the user entered an invalid username/password "error.jsp"

I want to show the user a neat error message on the login page instead of having him clicking on some link or press back to navigate to the login page again . can this be done ?


Solution

  • There is a tweak available which we used in a similar scenario.

    e.g. let us say the URL of your page is www.servername.com/login.html

    We provided the error page URL as www.servername.com/login.html?error=true

    We kept the url of error page same as that of login page, and passed a parameter in URL as error.

    In the login page, we checked if this parameter was true, we showed the error message.

    Later, we used the same parameter to show different kinds of error messages.