views:

292

answers:

2

I have an application running under WebLogic that is using standard forms authentication. The login page is a JSP that presents the login form that will post to j_security_check. So as you would expect, when a user tries to access a page but is not yet authenticated, they will be redirected to the login.jsp.

My question is, how can I determine the page that the user was attempting to hit before WebLogic redirected them to the login page? I wish to use this to change the content of the login page depending on the user's destination. I'm not seeing anything in the request ojbect that would tell me this.

Thanks for any hints!

A: 

It's stored as request attribute with the name javax.servlet.forward.request_uri.

Thus, you can access it by either EL in login JSP:

${requestScope['javax.servlet.forward.request_uri']}

or by raw Java code in either servlet or filter associated with login JSP, or in (cough) scriptlet:

request.getAttribute("javax.servlet.forward.request_uri");
BalusC
Thanks BalusC, but this attribute does not exist. In fact, request.getAttributeNames() returns an empty list. Perhaps the login page works differently from standard forwarding?
Chris Thornhill
Maybe weblogic uses an proprietary approach. Or you tested it the wrong way. You shouldn't open up the login page directly. By the way, Weblogic should not have literally **redirected** the request to the login page, but instead just **forwarded** the request to it. A redirect namely creates a brand new request, hereby losing all original attributes.
BalusC
A: 

We concluded there was no way to find out the target URL from the login page. I woudln't mind being proven wrong. :)

In the meantime, the solution was to deploy the content in second WAR with it's own login page providing the alternate content. Lots of overhead for what should be a simple problem to solve.

Chris Thornhill