You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Legolas Woodland <le...@gmail.com> on 2005/08/11 16:04:05 UTC

how i can redirect (without loosing session) to a full url from jsp page in struts.

Hi
Thank you for reading my post
I have a problem.
problem is :
I should go back to last visited page after my user login or changed
locale or ..
i can retrive las visited page : by using request.getheader("Referer")
and i store it into a session variable.
No after my user loged in i should forward?redirect? or sending
him/her back to that url
without loosing his/her session
Problem is : its a full url and i just can redirect ro a sub url in my
context? (pleas correct me if i am wrong)

how i can send my visitor back to thier page which i stored in session ?
for example is there any tag in jsp or struts for it?


Thank you

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how i can redirect (without loosing session) to a full url from jsp page in struts.

Posted by Laurie Harper <la...@holoweb.net>.
First, a couple of things you need to be aware of with this. The Referrer 
header is not guaranteed to be there; some browsers allow the user to 
disable it, some firewalls and proxys filter it, etc. So if you don't have 
full control of the environment from which your application is accessed, 
relying on Referrer is not a good idea. You also need to watch out for 
pages generated by POSTs. If your application every sends a page in 
response to a POST the the Referrer URL on the following request will not 
include POST data. Redirecting to that URL may have unexpected results, 
again depending on how your application works.

That said, if you are still happy to rely on Referrer, then you can perform 
a redirect to the URL no problem. Client-side redirects use absolute URLs; 
they don't have to go to the same application, or even host. You only need 
worry about turning the URL into a context relative URL if you want to do a 
/server side/ redirect (i.e. a forward).

If you want to do that, or if you want to avoid issues with Referrer, you 
might consider including the 'target return URL' as part of the request for 
your login form, i.e. generating it as part of each page.

L.

Legolas Woodland wrote:
> Hi
> Thank you for reading my post
> I have a problem.
> problem is :
> I should go back to last visited page after my user login or changed
> locale or ..
> i can retrive las visited page : by using request.getheader("Referer")
> and i store it into a session variable.
> No after my user loged in i should forward?redirect? or sending
> him/her back to that url
> without loosing his/her session
> Problem is : its a full url and i just can redirect ro a sub url in my
> context? (pleas correct me if i am wrong)
> 
> how i can send my visitor back to thier page which i stored in session ?
> for example is there any tag in jsp or struts for it?
> 
> 
> Thank you


-- 
Laurie Harper
Open Source advocate, Java geek: http://www.holoweb.net/laurie
Founder, Zotech Software: http://www.zotechsoftware.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org