You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Louis Leung <lo...@sun.com> on 2002/02/11 20:59:16 UTC

How to show the URL I want

Guys, anyone know how to send back the user the URL of the forward
mapping, without using the redirect ??  Because I will lose the session
if I use a redirect.



Currently, I have this :
    <action    path="/changeLocale"   type="ChangeLocaleAction">
                <forward name="continue"
path="/instructor/create.do"/>
    </action>

and the browser is showing this :
/changeLocale.do

I want the browser to show this :
/instructor/create.do

without using this :
<forward name="continue"   path="/instructor/create.do"  redirect =
"true"/>





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to show the URL I want

Posted by Max Cooper <ma...@maxcooper.com>.
There is no good (reliable) way to send a response that will instruct the
browser to change what appears on the location bar. It seems that the ideal
solution is to not have URLs like 'updateObject', etc. that the user should
not see or have in their browser history, which avoids the problem
completely but is not the common practice. However, there is at least one
way to do this that seems to work well enough...

The best way is to send an empty response with a redirect, but there are a
few issues to watch out for. If you session is identified with a cookie,
make sure that the response will redirect the user to a host:port that the
browser will send your session cookie to. Netscape is more picky in this
area, and views these URLs as distinct, which means it won't send the
cookies of one to the other:
http://host.domain.com/
http://host.domain.com:80/
https://host.domain.com/
https://host.domain.com:443/
One way to solve this is to set the cookie domain property of your app
server to something sufficiently general so that the browser will send it to
any of the above URLs. 'host.domain.com' would achieve that goal. There may
be more problems if you aren't using cookies, but I always use cookies so I
don't have any experience in that area. This seems to work well enough that
it is useful and reasonably reliable.

There are other ways, but they are not very reliable so I don't recommend
any of them. Also, I am not exactly sure of the details, so my descriptions
might be a little off. Setting the 'content-location' header on the response
can make the browser change its location bar, but this may not work reliably
and has been dropped from the HTTP spec, so it probably isn't a good
solution moving forward. There is also an HTML META tag, "bookmark" I think
it is, that might do this, too. You can probably write some JavaScript to do
it, too. However, I don't recommend any of these solutions; use redirects if
you must do this kind of thing.

-Max

----- Original Message -----
From: "Louis Leung" <lo...@sun.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, February 11, 2002 11:59 AM
Subject: How to show the URL I want


> Guys, anyone know how to send back the user the URL of the forward
> mapping, without using the redirect ??  Because I will lose the session
> if I use a redirect.
>
>
>
> Currently, I have this :
>     <action    path="/changeLocale"   type="ChangeLocaleAction">
>                 <forward name="continue"
> path="/instructor/create.do"/>
>     </action>
>
> and the browser is showing this :
> /changeLocale.do
>
> I want the browser to show this :
> /instructor/create.do
>
> without using this :
> <forward name="continue"   path="/instructor/create.do"  redirect =
> "true"/>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to show the URL I want

Posted by Jim Crossley <jc...@ifleet.com>.
It sounds as if you're using "URL-rewriting" instead of "Cookies" to
identify a client's session.  If so, you must ensure that the session
id is included in the URL to which you're redirecting your client.
Check the docs for your servlet container to see how they implement
sessions using URL-rewriting.  Or use cookies.

-- Jim

Louis Leung <lo...@sun.com> writes:

> But when i tried redirect="true", the session ids from before redirect and after
> redirect are different ..... and the stuffs i put in the session are all gone
> 
> Alex Paransky wrote:
> 
> > Why would you loose the session?  I have been using redirect="true" in some
> > of my actions without any problems.  The reason I needed to do it, was
> > because I did not want "saveItemInfo.do" appearing on the URL.  User
> > pressing, the RELOAD/REFRESH button would re-execute the save action.
> > Instead, I wanted to show the "saveItemInfoSuccess.do" page to appear.  The
> > redirect="true" allowed me to do this, without loosing the session.
> >
> > If the client lost the session, wouldn't client have to re-login again?
> >
> > -AP_
> >
> > -----Original Message-----
> > From: Louis Leung [mailto:louis.leung@sun.com]
> > Sent: Monday, February 11, 2002 11:59 AM
> > To: Struts Users Mailing List
> > Subject: How to show the URL I want
> >
> > Guys, anyone know how to send back the user the URL of the forward
> > mapping, without using the redirect ??  Because I will lose the session
> > if I use a redirect.
> >
> > Currently, I have this :
> >     <action    path="/changeLocale"   type="ChangeLocaleAction">
> >                 <forward name="continue"
> > path="/instructor/create.do"/>
> >     </action>
> >
> > and the browser is showing this :
> > /changeLocale.do
> >
> > I want the browser to show this :
> > /instructor/create.do
> >
> > without using this :
> > <forward name="continue"   path="/instructor/create.do"  redirect =
> > "true"/>
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How to show the URL I want

Posted by Louis Leung <lo...@sun.com>.
But when i tried redirect="true", the session ids from before redirect and after
redirect are different ..... and the stuffs i put in the session are all gone

Alex Paransky wrote:

> Why would you loose the session?  I have been using redirect="true" in some
> of my actions without any problems.  The reason I needed to do it, was
> because I did not want "saveItemInfo.do" appearing on the URL.  User
> pressing, the RELOAD/REFRESH button would re-execute the save action.
> Instead, I wanted to show the "saveItemInfoSuccess.do" page to appear.  The
> redirect="true" allowed me to do this, without loosing the session.
>
> If the client lost the session, wouldn't client have to re-login again?
>
> -AP_
>
> -----Original Message-----
> From: Louis Leung [mailto:louis.leung@sun.com]
> Sent: Monday, February 11, 2002 11:59 AM
> To: Struts Users Mailing List
> Subject: How to show the URL I want
>
> Guys, anyone know how to send back the user the URL of the forward
> mapping, without using the redirect ??  Because I will lose the session
> if I use a redirect.
>
> Currently, I have this :
>     <action    path="/changeLocale"   type="ChangeLocaleAction">
>                 <forward name="continue"
> path="/instructor/create.do"/>
>     </action>
>
> and the browser is showing this :
> /changeLocale.do
>
> I want the browser to show this :
> /instructor/create.do
>
> without using this :
> <forward name="continue"   path="/instructor/create.do"  redirect =
> "true"/>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: How to show the URL I want

Posted by Alex Paransky <al...@individualnetwork.com>.
Why would you loose the session?  I have been using redirect="true" in some
of my actions without any problems.  The reason I needed to do it, was
because I did not want "saveItemInfo.do" appearing on the URL.  User
pressing, the RELOAD/REFRESH button would re-execute the save action.
Instead, I wanted to show the "saveItemInfoSuccess.do" page to appear.  The
redirect="true" allowed me to do this, without loosing the session.

If the client lost the session, wouldn't client have to re-login again?

-AP_

-----Original Message-----
From: Louis Leung [mailto:louis.leung@sun.com]
Sent: Monday, February 11, 2002 11:59 AM
To: Struts Users Mailing List
Subject: How to show the URL I want


Guys, anyone know how to send back the user the URL of the forward
mapping, without using the redirect ??  Because I will lose the session
if I use a redirect.



Currently, I have this :
    <action    path="/changeLocale"   type="ChangeLocaleAction">
                <forward name="continue"
path="/instructor/create.do"/>
    </action>

and the browser is showing this :
/changeLocale.do

I want the browser to show this :
/instructor/create.do

without using this :
<forward name="continue"   path="/instructor/create.do"  redirect =
"true"/>





--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>