dev@glassfish.java.net

Re: Possible bug in servlet

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 09 Jun 2008 10:03:16 +0200

Jan.Luehe_at_Sun.COM wrote:
> Paul Sandoz wrote:
>
>> Jan.Luehe_at_Sun.COM wrote:
>>
>>> A request for
>>>
>>> http://localhost:8080/HelloWorldWebApp
>>>
>>> will cause a redirect to
>>>
>>> http://localhost:8080/HelloWorldWebApp/
>>>
>>> which matches your servlet.
>>>
>>
>> I still think there may be an issue because the information returned
>> from HttpServletRequest is inconsistent. Namely, i observe:
>>
>> request.getPathInfo() = "/"
>> request.getRequestURI() = "/HelloWorldWebApp"
>> request.getRequestURL() = "http://localhost:8080/HelloWorldWebApp"
>>
>> i.e. the latter two should end in a '/' if redirection correctly is
>> performed.
>>
>> I presume an internal redirect is performed: I just checked using curl
>> and no 303 response is returned.
>>
>> Is the redirection GF specific behavior? Is it possible to switch it off?
>
>
> I'm trying to find the exact quote from the Servlet spec, but Section
> 10.10 (Welcome Files) has this:
>
> A request URI of /foo will be redirected to a URI of /foo/.
>

Presumably that would only occur if one or more welcome files were
present in the web.xml ?


> I've verified (using telnet) that a redirect is actually being returned:
>

I don't observe that behavior. What version of GF are you using? I am
using GF v2 UR2.

See attached for about the simplest WebApplication possible created with
NB 6.0. It contains just one servlet that prints out information in the
servlet request.

curl outputs the following:

> curl -v http://localhost:8080/WebApplication14
   * About to connect() to localhost port 8080
   * Trying 127.0.0.1... connected
   * Connected to localhost (127.0.0.1) port 8080
> GET /WebApplication14 HTTP/1.1
> User-Agent: curl/7.15.5 (i386-pc-solaris2.11) libcurl/7.15.5
OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.8
> Host: localhost:8080
> Accept: */*
>
   < HTTP/1.1 200 OK
   < X-Powered-By: Servlet/2.5
   < Server: Sun Java System Application Server 9.1_02
   < Content-Type: text/html; charset=iso-8859-1
   < Content-Length: 0
   < Date: Mon, 09 Jun 2008 07:57:25 GMT
   * Connection #0 to host localhost left intact
   * Closing connection #0

Curl by default does not follow redirects.

The application prints out in the GF log:

   Request URI: /WebApplication14
   Request URL: http://localhost:8080/WebApplication14
     Path Info: /

No redirection occurs and the information in the request is inconsistent.

Can you test with the attached application to see if you observe the
same behaviour as I?

Thanks,
Paul.

> GET /123 HTTP/1.0
>
> HTTP/1.1 302 Moved Temporarily
> X-Powered-By: Servlet/2.5
> Location: http://leah:8080/123/
> Content-Type: text/html; charset=iso-8859-1
> Date: Sat, 07 Jun 2008 00:37:17 GMT
> Connection: close
>
>
> Jan
>
>>
>> Paul.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109