You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Nicola Ken Barozzi <ni...@apache.org> on 2002/12/04 17:00:52 UTC

Redirect problem in Cocoon+Jetty... or is it Tomcat?

Grab the latest Cocoon from CVS, and launch "build run".
Then point the browser to http://localhost:8888/

The redirect doesn't work it seems...

Then point to http://localhost:8888/samples/
It should redirect to http://localhost:8888/samples/welcome but instead 
it redirects to http://localhost:8888/welcome (one step back)

Then goto http://localhost:8888/samples/misc
It redirects to http://localhost:8888/samples/welcome

Now, if I put a / in front of the redirect url (should be relative to 
servlet context, no?) it seems to work.

There is something wrong with the redirection-resolving, but honestly I 
don't know if the problem is in Tomcat, that makes it all work, Cocoon 
or Jetty.

What is the correct behaviour?

-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Redirect problem in Cocoon+Jetty... or is it Tomcat?

Posted by Vadim Gritsenko <va...@verizon.net>.
Nicola Ken Barozzi wrote:

>
> Grab the latest Cocoon from CVS, and launch "build run".
> Then point the browser to http://localhost:8888/
>
> The redirect doesn't work it seems...
>
> Then point to http://localhost:8888/samples/
> It should redirect to http://localhost:8888/samples/welcome but 
> instead it redirects to http://localhost:8888/welcome (one step back)
>
> Then goto http://localhost:8888/samples/misc
> It redirects to http://localhost:8888/samples/welcome
>
> Now, if I put a / in front of the redirect url (should be relative to 
> servlet context, no?) it seems to work.
>
> There is something wrong with the redirection-resolving, but honestly 
> I don't know if the problem is in Tomcat, that makes it all work, 
> Cocoon or Jetty.
>
> What is the correct behaviour? 


I believe that correct behavior of servlet engine is to not mess with 
redirect URL but send them to browser without change, and browser should 
interpret them.
Thus, redirect without starting "/" should work without problem.

WebSphere (some 4.0.?? versions ) is known to do weird things with 
redirect URLs, grep Cocoon sources for "WebSphere" to see a workaround.

Vadim



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Redirect problem in Cocoon+Jetty... or is it Tomcat?

Posted by Nicola Ken Barozzi <ni...@apache.org>.

Bernhard Huber wrote:
> hi,
> 
>>
>> Grab the latest Cocoon from CVS, and launch "build run".
>> Then point the browser to http://localhost:8888/
>>
>> The redirect doesn't work it seems...
>>
>> Then point to http://localhost:8888/samples/
>> It should redirect to http://localhost:8888/samples/welcome but 
>> instead it redirects to http://localhost:8888/welcome (one step back)
>>
>> Then goto http://localhost:8888/samples/misc
>> It redirects to http://localhost:8888/samples/welcome
>>
>> Now, if I put a / in front of the redirect url (should be relative to 
>> servlet context, no?) it seems to work.
>>
>> There is something wrong with the redirection-resolving, but honestly 
>> I don't know if the problem is in Tomcat, that makes it all work, 
>> Cocoon or Jetty.
>>
>> What is the correct behaviour?
>>
> As much as i remember relative redirects are not correct in a strict
> sense, the servlet rfc spec say that redirects should be always absolute.

I have finally taken the time to hunt down the latast servlet 2.3 
javadocs on redirects:
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletResponse.html#sendRedirect(java.lang.String)

"
public void sendRedirect(java.lang.String location)
                   throws java.io.IOException

     Sends a temporary redirect response to the client using the
     secified redirect location URL. This method can accept
     relative URLs; the servlet container must convert the
     relative URL to an absolute URL before sending the response
     to the client. If the location is relative without a
     leading '/' the container interprets it as relative to
     the current request URI. If the location is relative
     with a leading '/' the container interprets it as
     relative to the servlet container root.
"

->  the servlet container must convert the
     relative URL to an absolute URL before sending the response
     to the client.

Seems like it's a Jetty bug then, no?

Since we are using a system that has an environment abstraction, it 
probably would make sense if we did that relative->absolute resolving 
ourselves, no?

> Weblogic and probably tomcat are relaxing this converting relative 
> redirectURLs to absolute urls.
> 
> anyway a trace first jetty, next tomcat
> jetty redirects for /samples/ to location /welcome
> 
> tomcat redirects for /cocoon2-local/samples/ to  location 
> /cocoon2-local/samples/welcome
> 
> I think the most correct way is to fix Cocoon sending only absolute 
> redirect URLs

My opinion too, which is ok for me since it maintains maximum backard 
compatibility, and less problems in the future.


-- 
Nicola Ken Barozzi                   nicolaken@apache.org
             - verba volant, scripta manent -
    (discussions get forgotten, just code remains)
---------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Redirect problem in Cocoon+Jetty... or is it Tomcat?

Posted by Bernhard Huber <be...@a1.net>.
hi,

> 
> Grab the latest Cocoon from CVS, and launch "build run".
> Then point the browser to http://localhost:8888/
> 
> The redirect doesn't work it seems...
> 
> Then point to http://localhost:8888/samples/
> It should redirect to http://localhost:8888/samples/welcome but instead 
> it redirects to http://localhost:8888/welcome (one step back)
> 
> Then goto http://localhost:8888/samples/misc
> It redirects to http://localhost:8888/samples/welcome
> 
> Now, if I put a / in front of the redirect url (should be relative to 
> servlet context, no?) it seems to work.
> 
> There is something wrong with the redirection-resolving, but honestly I 
> don't know if the problem is in Tomcat, that makes it all work, Cocoon 
> or Jetty.
> 
> What is the correct behaviour?
> 
As much as i remember relative redirects are not correct in a strict
sense, the servlet rfc spec say that redirects should be always absolut.

Weblogic and probably tomcat are relaxing this converting relative 
redirectURLs to absolute urls.

anyway a trace first jetty, next tomcat
jetty redirects for /samples/ to location /welcome

tomcat redirects for /cocoon2-local/samples/ to  location 
/cocoon2-local/samples/welcome

I think the most correct way is to fix Cocoon sending only absolute 
redirect URLs

any comments ?
bye bernhard


<jetty>
------ localhost:1499->localhost:8888 ------
GET /samples/ HTTP/1.1
Host: localhost:8079
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2) 
Gecko/20021126
Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Accept-Language: en-us, en;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive


------ localhost:8888->localhost:1499 ------
HTTP/1.1 302 Moved Temporarily
Date: Fri, 6 Dec 2002 20:45:56 GMT
Server: Jetty/4.1.2 (Windows 2000 5.0 x86)
Servlet-Engine: Jetty/4.1.2 (Servlet 2.3; JSP 1.2; java 1.4.1)
X-Cocoon-Version: 2.1-dev
Location: http://localhost:8079/welcome
Transfer-Encoding: chunked

</jetty>

<tomcat>

------ localhost:1507->localhost:8080 ------
GET /cocoon2-local/samples/ HTTP/1.1
Host: localhost:8079
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2) 
Gecko/20021126
Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1
Accept-Language: en-us, en;q=0.50
Accept-Encoding: gzip, deflate, compress;q=0.9
Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
Keep-Alive: 300
Connection: keep-alive


------ localhost:8080->localhost:1507 ------
HTTP/1.1 302 Moved Temporarily
X-Cocoon-Version: 2.1-dev
Location: http://localhost:8079/cocoon2-local/samples/welcome
Content-Type: text/html;charset=ISO-8859-1
Content-Language: de-AT
Transfer-Encoding: chunked
Date: Fri, 06 Dec 2002 20:51:31 GMT
Server: Apache Coyote/1.0

2b0
<html><head><title>Apache Tomcat/4.1.12 - Error 
report</title><STYLE><!--H1{font-family : sans-serif,Arial,Tahoma;color 
: white;background-color : #0086b2;} H3{font-family : 
sans-serif,Arial,Tahoma;color : white;background-color : #0086b2;} 
BODY{font-family : sans-serif,Arial,Tahoma;color : 
black;background-color : white;} B{color : white;background-color : 
#0086b2;} HR{color : #0086b2;} --></STYLE> </head><body><h1>HTTP Status 
302 - </h1><HR size="1" noshade><p><b>type</b> Status 
report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The 
requested resource () has moved temporarily to a new 
location.</u></p><HR size="1" noshade><h3>Apache 
Tomcat/4.1.12</h3></body></html>
0

</tomcat>



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org