users@jersey.java.net

Re: Matrix Parameter With URL Value Ends Up With 404

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 19 Oct 2007 12:08:19 +0200

This is because

   com.sun.ws.rest.impl.container.servlet.HttpRequestAdaptor

works from decoded path.

It needs to consistently work from the encoded path and avoid calling
servlet.getPathInfo (which is buggy on some servlet implementations).

This is a little tricky because servlet does not directly support access
to the context, servlet and path info in encoded form.

For now we can probably get away with constructing a decoded base path
from the context path and servlet path and then encoding it, as such
paths are unlikely to have round trip issues (and we can detect if they
do and throw an error).

Once the encoded base path is obtained it should be easy to extract the
encoded path from the encoded base path and request URI (which in
encoded form), since the latter should begin with the former.


Part of larger problem is we don't yet have automated tests set up for
servlet containers. We will be making some steps to improve this area
soon. The end result i would like to see is the ability to create a unit
test module that contains client code, service code (independent of
container) such that it can be deployed tested on any supported HTTP
container.

Paul.

Jakub Podlesak wrote:
> Hi Hien,
>
> Thank you for finding this out. On a http container it works fine,
> while on a servlet container it fails as you describe (tested on Tomcat, Glassfish).
> (Well, I got 400 instead of 404; not happy with that anyway)
>
> I need to get some sleep. Tomorow I will look at it more detail.
> If you want, please file a bug at [1] and attach your webapp as a reproducible test case.
>
> Thanks.
>
> ~Jakub
>
> [1]https://jersey.dev.java.net/issues/
>
> On Thu, Oct 18, 2007 at 02:51:13PM -0700, Hien Luu wrote:
>> Hi,
>>
>> I have a resource class that takes a matrix parameter and the value is a URL like 'http://www.yahoo.com'. Obviously the URL is URL encoded on the client side before making a GET request.
>>
>> This is what it looks like on the client side:
>> http://localhost:8080/myresource;url=http%3A%2F%2Fwww.yahoo.com>
>>
>> When the above request URL gets to the server side, it will look something like this:
>> http://localhost:8080/myresource;url=http://www.yahoo.com
>>
>> The WebApplicationImpl.stripMatrixParams() method doesn't seem to parse the above URL correctly.
>>
>> For example if the input to the method stripMatrixParams() is '/myresource;url=http://www.yahoo.com', the output is
>> '/myresource//www.yahoo.com'. Because of this the RootResourceClass.dispatch() method will not able to find a UriTemplateDispatcher and ends up being a 404 response.
>>
>> Has anyone encounter this problem before?
>>
>> Thanks,
>>
>> Hien
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

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