users@jersey.java.net

Re: [Jersey] Escaping a PathParam slash

From: dloy <david.loy_at_ucop.edu>
Date: Tue, 18 Aug 2009 09:10:22 -0700

Hi Paul
Unfortunately your server is down right now so I haven't been able to
follow up on the logging filter. I include the code and results using a
Firefox browser to a tomcat server on Windows XP. This is using jersey 1.1.0

Admittedly, the browser may be doing something in between. BUT, Note that

URL: http://localhost:28080/jjersey/testIt/test/first/second/third
Results in the error: The requested resource () is not available.

while
URL:http://localhost:28080/jjersey/testIt/test/first/second%2fthird
Results in a blank screen

For non-%2f escape sequences Jersey is able to insert the character

 From this it appears that jersey is not handling %2f like a / but,
also, it is not treating it as an embedded escaped character.

Sorry to push to get this resolved but if Jersey cannot escape a / we
will not be able to use it without providing our own escape mechanism.

I will continue to try and get what I need for the log filtering.

Thanks so much
David

Code:
package org.cdlib.test;

import javax.ws.rs.GET;
import javax.ws.rs.PathParam;
import javax.ws.rs.Path;

@Path ("/testIt")
public class TestIt {
@GET
@Path("test/{item1}/{item2}")
public String getFileState(
@PathParam("item1") String item1,
@PathParam("item2") String item2)
{
return "**" + item1 + "**" + item2;
}
}

Results:
http://localhost:28080/jjersey/testIt/test/first/second
**first**second

http://localhost:28080/jjersey/testIt/test/first/second/third
Browser reports back error: The requested resource () is not available.

http://localhost:28080/jjersey/testIt/test/first/second%2ethird
**first**second.third

http://localhost:28080/jjersey/testIt/test/first/second%2fthird
blank screen

http://localhost:28080/jjersey/testIt/test/first/second0third
**first**second0third

http://localhost:28080/jjersey/testIt/test/first/second%a9third
**first**second?third

Paul Sandoz wrote:
>
> On Aug 18, 2009, at 1:30 AM, dloy wrote:
>
>> I have a PathParam that contains a forward slash(data/fptr11.xls). Is
>> there a mechanism for escaping the slash within Jersey? I tried URL
>> Encoding (data%2Ffptr11.xls) in firefox- this got no response - it
>> appears to repost whatever screen is there. URL Encoding with other
>> values than %2F appears to work.
>>
>> To verify this I put in code to convert a $ to /. So data$fptr11.xls
>> AND data%24fptr11.xls both work properly so the URL Encoding does
>> seem to work for other characters.
>>
>
> What Web container are you using?
>
> I suspect that the Web container is not correctly managed %2F and the
> value is getting decoded before it reaches Jersey and then matching
> will fail and return a 404 response.
>
> You can verify if this is the case by adding request/response logging
> to the server side:
>
> https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
>
>
> Paul.
>
>> Any ideas?
>> Thanks
>> David
>>
>> Example URL:
>> http://localhost:28080/jstore/fileState/15/12345-abcde/2/data%2ffptr11.xls
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>