Skip to main content

redirect the user once logged in to the requested page

4 replies [Last post]
pradyut
Offline
Joined: 2004-07-13

Hi
I have a form realm authentication
with which i am securing a directory "secureUser"

well my question is: -
How i can redirect the user once logged in to the requested page

the details: -

now i can log on a user using this (login.jsp)

==============================================================

==============================================================

Now a user requests two or more pages in the same session browser (firefox/ie tabs)
"secureUser/one.jsp"
"secureUser/two.jsp"
"secureUser/three.jsp"

Now the user gets a login form page thats login.jsp for all the three requested pages

The user authenticates into the page requested "secureUser/one.jsp"

Now if the user reloads the page "secureUser/two.jsp" or "secureUser/three.jsp" which is now showing login.jsp
he gets the same login.jsp page

How i can redirect the user after logging in once to the requested page
such that the page login.jsp after reloading goes to referred page

I can do this in the login.jsp page

==============================================================
java.security.Principal obj = request.getUserPrincipal();

if(obj!=null)
{
response.sendRedirect("secureUser/one.jsp");
}

==============================================================

but i cannot get the referred page such as two.jsp or three.jsp

Thanks
Pradyut

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Lincoln Baxter, III

This is a Spring Security related question, not a JSF / GlassFish question
;) but it's still a good question. You can read this article for your
solution:

http://ocpsoft.com/java/jsf-java/spring-security-what-happens-after-you-...

--Lincoln

On Thu, Mar 4, 2010 at 11:29 PM, wrote:

> Hi
> I have a form realm authentication
> with which i am securing a directory "secureUser"
>
> well my question is: -
> How i can redirect the user once logged in to the requested page
>
> the details: -
>
> now i can log on a user using this (login.jsp)
>
> ==============================================================
>
>

> id="login_from">
>

> > id="j_username" title="EmailID" />
>

>

> > id="j_password" title="Password" />
>

>

> > value="Login" />
>

>

>
> ==============================================================
>
> Now a user requests two or more pages in the same session browser
> (firefox/ie tabs)
> "secureUser/one.jsp"
> "secureUser/two.jsp"
> "secureUser/three.jsp"
>
> Now the user gets a login form page thats login.jsp for all the three
> requested pages
>
> The user authenticates into the page requested "secureUser/one.jsp"
>
> Now if the user reloads the page "secureUser/two.jsp" or
> "secureUser/three.jsp" which is now showing login.jsp
> he gets the same login.jsp page
>
> How i can redirect the user after logging in once to the requested page
> such that the page login.jsp after reloading goes to referred page
>
> I can do this in the login.jsp page
>
> ==============================================================
> java.security.Principal obj = request.getUserPrincipal();
>
> if(obj!=null)
> {
> response.sendRedirect("secureUser/one.jsp");
> }
>
> ==============================================================
>
> but i cannot get the referred page such as two.jsp or three.jsp
>
> Thanks
> Pradyut
> [Message sent by forum member 'pradyut' (pradyut100@yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=390185
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

tacitust
Offline
Joined: 2010-02-24

Forgive me if I am mistaken, but he is talking about the built-in J2EE container security that uses the HttpServletRequest APIs and not Spring Security (though I am guessing the former was derived from the latter).

I certainly didn't use any Spring stuff when I had my related problem.

Lincoln Baxter, III

I could be wrong, but the form URL and input names are those standard to the
Spring Security module:

title="Password" />

I should have said, "This /*seems*/ to be a spring security related
question, not a ... "

:)

On Fri, Mar 5, 2010 at 4:55 PM, wrote:

> Forgive me if I am mistaken, but he is talking about the built-in J2EE
> container security that uses the HttpServletRequest APIs and not Spring
> Security (though I am guessing the former was derived from the latter).
>
> I certainly didn't use any Spring stuff when I had my related problem.
> [Message sent by forum member 'tacitust' (tacitus@yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=390316
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>

--
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
[att1.html]

tacitust
Offline
Joined: 2010-02-24

The format of your message is a bit messed up, but are you saying that after the user has logged in once, he still gets sent back to the login page again when he tries to go to the second page when he should already be authenticated like this:

p1 --> login --> p1 ---> p2 --> login

If that's the case, then I am having a similar problem. I am using my own login page and then calling httpServletRequest#login(), but I am also being sent back to the login page as soon as I do anything else -- even doing something on the same page. The login credentials are being lost, and I have no idea why.

I haven't had any answers yet - but some working demo code would be really nice :)

Message was edited by: tacitust