• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3440
  • Last Modified:


i'm using form based security in jboss with j_security_check

the problem is when i access login.jsp directly and try to login it gives an invalid page reference error 400.  

how can i make it so that u can login by going to the login.jsp directly and then it sends you to a page based on the role of your entered username?  if ur the admin role it sends to admin.jsp and if its in user role it sends to somethingelse.jsp
1 Solution
First of all you should not go directly to login.jsp.
You just call a protected page (protected by <security-constraint> element ) and Tomcat (web server of jboss) will first  call login.jsp to perform authentication and if it is succesful will load protected page. In this page you can check then user roles and forward to necessary URL based on role.

Let illustrate it with an example.
So you have following directory structure in your webapp:

in your web.xml you add following:
              <web-resource-name>Sample Application</web-resource-name>
              <description>Require users to authenticate</description>
            <description>admin users</description>
            <description>Other users</description>


In your firstpage.jsp you do checkup user roles and based on that forward to necessary URL:

Deploy your web app. And in browser enter http://your-host:8080/yourwebappPath/protected/firstpage.jsp

And based on your user role you will be redirected to necessary page

drop the prefix "/" from the url pattern and try ...

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

I think my answer could be accepted as correct one. We had exactly the sameproblem and my solution works perfectly and explains the behaviour
i would say still drop the prefix "/" from the url pattern , it will work...
I kinda love experts that ignore pings and then come asking for points.


The question is how to go to it directly. Yes - you are giving a nice idea but unless the asker shows up, it does not really answer the question, does it? For all we know - he may have some business reason to want it like this.

From which pattern? Where do you know what he has in the prefix when he had never posted a pattern? :)
The way it is asked will not work in Tomcat. I was  facing the same problem during of one of my implementations.
I want just call j_security_check from my URL, but got error 400. It works only the way I described
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now