You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by jfc <jf...@btopenworld.com> on 2002/11/22 01:42:19 UTC

does tomcat automatically revert to url rewriting...

Hi

I'm using struts1.1b2, tomcat 406 and jboss3

1. Does tomcat automatically revert to url rewriting when the browser 
doesn't support cookies?
2. If not, do I have to do something to enforce url rewriting?

I want to do whatever it takes to track sessions in my application.

jfc



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


Re: does tomcat automatically revert to url rewriting...

Posted by Tim Funk <fu...@joedog.org>.
jfc wrote:
> Tim Funk wrote:
> 
>> To use URL rewriting all your URLS must first wrapped in
>> response.encodeRedirectURL()
> 
> 
> So does this mean that tomcat does not automatically do the encoding in 
> the absence of cookies?

If you use response.encodeRedirectURL(), it will. But if your URL's are 
not wrapped in response.encodeRedirectURL(), you'll be SOL regardless of 
the servlet engine you use.

> 
>>
>> That being said:
>> response.encodeRedirectURL() will rewrite the URL to add jsessionid if 
>> there was no incoming session cookie.
>>
>> AFAIK - tomcat will not go through the effort of rewriting the URL if 
>> the session can be persisted via the cookie.
> 
> 
> Will tomcat *automatically* go through the effort of rewriting the URL 
> if the session *cannot* be persisted via the cookie?(i.e. do I need to 
> watch for clients that don't support cookies or can I rest assured that 
> tomcat knows whether or not a request has a cookie and so when cookies 
> are not there then it encodes each request for me?)
> 

Yes - with the above condition that all urls are wrapped in 
response.encodeRedirectURL()





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


Re: does tomcat automatically revert to url rewriting...

Posted by jfc <jf...@btopenworld.com>.
Craig R. McClanahan wrote:

>On Fri, 22 Nov 2002, jfc wrote:
>
>  
>
>>Date: Fri, 22 Nov 2002 11:11:28 +0000
>>From: jfc <jf...@btopenworld.com>
>>Reply-To: Tomcat Users List <to...@jakarta.apache.org>
>>To: Tomcat Users List <to...@jakarta.apache.org>
>>Subject: Re: does tomcat automatically revert to url rewriting...
>>
>>Craig R. McClanahan wrote:
>>
>>    
>>
>>>On Fri, 22 Nov 2002, jfc wrote:
>>>
>>>
>>>
>>>      
>>>
>>>>Will tomcat *automatically* go through the effort of rewriting the URL
>>>>if the session *cannot* be persisted via the cookie?(i.e. do I need to
>>>>watch for clients that don't support cookies or can I rest assured that
>>>>tomcat knows whether or not a request has a cookie and so when cookies
>>>>are not there then it encodes each request for me?)
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>Tomcat does indeed know if a session id cookie was received (and you can
>>>find out as well, by calling request.isSessionIdFromCookie()).  If that is
>>>the case, response.encodeURL() and response.encodeRedirectURL() will
>>>return the argument unmodified.
>>>
>>>
>>>      
>>>
>>OK. So that means I don't need to be concerned with when I should use
>>the call(s) and when I should not - I should always wrap my links and
>>redirects in these calls. (assuming my application uses sessions)
>>
>>    
>>
>
>Yes.
>
>  
>
>>>One subtlety should be pointed out, though -- consider what happens on the
>>>very first response for a new session.  At that point in time, Tomcat has
>>>no idea whether the client supports cookies or not.  Therefore, it sends
>>>the session id both ways (rewriting and a cookie).  On subsequent
>>>requests, if the cookie has been returned, Tomcat will stop rewriting.
>>>
>>>
>>>      
>>>
>>ok.
>>
>>    
>>
>>>We also need to remember that Tomcat does *not* scan the output your
>>>servlet or JSP page creates, and modifies the hyperlinks.  If you do not
>>>call encodeURL() or encodeRedirectURL() yourself when creating the output,
>>>URL rewriting will never occur (and your app will require the client to
>>>support cookies if it uses sessions).
>>>
>>>
>>>      
>>>
>>ok. I've got that.
>>
>>Now, I am using struts 1.1b2 so if I have <html:link> tags (and the
>>others tags which render urls) embedded in my jsps, should I wrap these
>>tags manually or does struts do the wrapping? If struts automatically
>>does it for me (as the docs suggest) then the above answer for me (using
>>struts) is not relevent.
>>
>>Correct?
>>
>>    
>>
>
>Yes.  The Struts tags that generate URLs all do the encodeURL() calls for
>you, so you don't have to think about it.
>
>  
>
>>>Craig
>>>
>>>
>>>
>>>      
>>>
>>jfc
>>    
>>
>
>Craig
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>  
>
Thanks Craig!

jfc



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


Re: does tomcat automatically revert to url rewriting...

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 22 Nov 2002, jfc wrote:

> Date: Fri, 22 Nov 2002 11:11:28 +0000
> From: jfc <jf...@btopenworld.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: Tomcat Users List <to...@jakarta.apache.org>
> Subject: Re: does tomcat automatically revert to url rewriting...
>
> Craig R. McClanahan wrote:
>
> >On Fri, 22 Nov 2002, jfc wrote:
> >
> >
> >
> >>Will tomcat *automatically* go through the effort of rewriting the URL
> >>if the session *cannot* be persisted via the cookie?(i.e. do I need to
> >>watch for clients that don't support cookies or can I rest assured that
> >>tomcat knows whether or not a request has a cookie and so when cookies
> >>are not there then it encodes each request for me?)
> >>
> >>
> >>
> >
> >Tomcat does indeed know if a session id cookie was received (and you can
> >find out as well, by calling request.isSessionIdFromCookie()).  If that is
> >the case, response.encodeURL() and response.encodeRedirectURL() will
> >return the argument unmodified.
> >
> >
> OK. So that means I don't need to be concerned with when I should use
> the call(s) and when I should not - I should always wrap my links and
> redirects in these calls. (assuming my application uses sessions)
>

Yes.

> >One subtlety should be pointed out, though -- consider what happens on the
> >very first response for a new session.  At that point in time, Tomcat has
> >no idea whether the client supports cookies or not.  Therefore, it sends
> >the session id both ways (rewriting and a cookie).  On subsequent
> >requests, if the cookie has been returned, Tomcat will stop rewriting.
> >
> >
> ok.
>
> >We also need to remember that Tomcat does *not* scan the output your
> >servlet or JSP page creates, and modifies the hyperlinks.  If you do not
> >call encodeURL() or encodeRedirectURL() yourself when creating the output,
> >URL rewriting will never occur (and your app will require the client to
> >support cookies if it uses sessions).
> >
> >
> ok. I've got that.
>
> Now, I am using struts 1.1b2 so if I have <html:link> tags (and the
> others tags which render urls) embedded in my jsps, should I wrap these
> tags manually or does struts do the wrapping? If struts automatically
> does it for me (as the docs suggest) then the above answer for me (using
> struts) is not relevent.
>
> Correct?
>

Yes.  The Struts tags that generate URLs all do the encodeURL() calls for
you, so you don't have to think about it.

> >Craig
> >
> >
> >
> jfc

Craig


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


Re: does tomcat automatically revert to url rewriting...

Posted by jfc <jf...@btopenworld.com>.
Craig R. McClanahan wrote:

>On Fri, 22 Nov 2002, jfc wrote:
>
>  
>
>>Will tomcat *automatically* go through the effort of rewriting the URL
>>if the session *cannot* be persisted via the cookie?(i.e. do I need to
>>watch for clients that don't support cookies or can I rest assured that
>>tomcat knows whether or not a request has a cookie and so when cookies
>>are not there then it encodes each request for me?)
>>
>>    
>>
>
>Tomcat does indeed know if a session id cookie was received (and you can
>find out as well, by calling request.isSessionIdFromCookie()).  If that is
>the case, response.encodeURL() and response.encodeRedirectURL() will
>return the argument unmodified.
>  
>
OK. So that means I don't need to be concerned with when I should use 
the call(s) and when I should not - I should always wrap my links and 
redirects in these calls. (assuming my application uses sessions)

>One subtlety should be pointed out, though -- consider what happens on the
>very first response for a new session.  At that point in time, Tomcat has
>no idea whether the client supports cookies or not.  Therefore, it sends
>the session id both ways (rewriting and a cookie).  On subsequent
>requests, if the cookie has been returned, Tomcat will stop rewriting.
>  
>
ok.

>We also need to remember that Tomcat does *not* scan the output your
>servlet or JSP page creates, and modifies the hyperlinks.  If you do not
>call encodeURL() or encodeRedirectURL() yourself when creating the output,
>URL rewriting will never occur (and your app will require the client to
>support cookies if it uses sessions).
>  
>
ok. I've got that.

Now, I am using struts 1.1b2 so if I have <html:link> tags (and the 
others tags which render urls) embedded in my jsps, should I wrap these 
tags manually or does struts do the wrapping? If struts automatically 
does it for me (as the docs suggest) then the above answer for me (using 
struts) is not relevent.

Correct?

>Craig
>
>  
>
jfc

>--
>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: does tomcat automatically revert to url rewriting...

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 22 Nov 2002, jfc wrote:

>
> Will tomcat *automatically* go through the effort of rewriting the URL
> if the session *cannot* be persisted via the cookie?(i.e. do I need to
> watch for clients that don't support cookies or can I rest assured that
> tomcat knows whether or not a request has a cookie and so when cookies
> are not there then it encodes each request for me?)
>

Tomcat does indeed know if a session id cookie was received (and you can
find out as well, by calling request.isSessionIdFromCookie()).  If that is
the case, response.encodeURL() and response.encodeRedirectURL() will
return the argument unmodified.

One subtlety should be pointed out, though -- consider what happens on the
very first response for a new session.  At that point in time, Tomcat has
no idea whether the client supports cookies or not.  Therefore, it sends
the session id both ways (rewriting and a cookie).  On subsequent
requests, if the cookie has been returned, Tomcat will stop rewriting.

We also need to remember that Tomcat does *not* scan the output your
servlet or JSP page creates, and modifies the hyperlinks.  If you do not
call encodeURL() or encodeRedirectURL() yourself when creating the output,
URL rewriting will never occur (and your app will require the client to
support cookies if it uses sessions).

Craig


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


Re: does tomcat automatically revert to url rewriting...

Posted by jfc <jf...@btopenworld.com>.
Tim Funk wrote:

> To use URL rewriting all your URLS must first wrapped in
> response.encodeRedirectURL()

So does this mean that tomcat does not automatically do the encoding in 
the absence of cookies?

>
> That being said:
> response.encodeRedirectURL() will rewrite the URL to add jsessionid if 
> there was no incoming session cookie.
>
> AFAIK - tomcat will not go through the effort of rewriting the URL if 
> the session can be persisted via the cookie.

Will tomcat *automatically* go through the effort of rewriting the URL 
if the session *cannot* be persisted via the cookie?(i.e. do I need to 
watch for clients that don't support cookies or can I rest assured that 
tomcat knows whether or not a request has a cookie and so when cookies 
are not there then it encodes each request for me?)

>
>
> jfc wrote:
>
>> Hi
>>
>> I'm using struts1.1b2, tomcat 406 and jboss3
>>
>> 1. Does tomcat automatically revert to url rewriting when the browser 
>> doesn't support cookies?
>> 2. If not, do I have to do something to enforce url rewriting?
>>
>> I want to do whatever it takes to track sessions in my application.
>>
>> jfc
>>
>>
>>  
>
>
>
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>

jfc


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


Re: does tomcat automatically revert to url rewriting...

Posted by Tim Funk <fu...@joedog.org>.
To use URL rewriting all your URLS must first wrapped in
response.encodeRedirectURL()

That being said:
response.encodeRedirectURL() will rewrite the URL to add jsessionid if 
there was no incoming session cookie.

AFAIK - tomcat will not go through the effort of rewriting the URL if 
the session can be persisted via the cookie.


jfc wrote:
> Hi
> 
> I'm using struts1.1b2, tomcat 406 and jboss3
> 
> 1. Does tomcat automatically revert to url rewriting when the browser 
> doesn't support cookies?
> 2. If not, do I have to do something to enforce url rewriting?
> 
> I want to do whatever it takes to track sessions in my application.
> 
> jfc
> 
> 
>  


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