users@jersey.java.net

[Jersey] interesting path parameter behavior with URL encoded strings

From: Michael Frank <phrostbyte911_at_gmail.com>
Date: Thu, 19 Apr 2012 18:36:57 -0400

I'm writing a Resource where you could pass in URL encoded strings as path
parameters. What I have found is that this doesn't always work.

My path annotation is: *_at_Path("/list/add/{value}")*

My listener method looks like *public Response
addToList(@PathParam("value") String value)*
*
*
What I have found is calling this resource with the url */list/add/one%20two
* works as I'd expect. It creates the variable *value *with the string *"one
two"*.

However if I call this resource with the url */list/add/one%2Ftwo * then I
get a 400 Bad Request response and the listener is never called. What is
fun is that calling */list/add/one/two* will actually work in this case
since the regex matching is greedy. In my case I'm passing in whole URLs.
 So passing */list/add/https://host.com/item/93939* will work and *value *will
be set to *https://host.com/item/93939* even though at this point I'm
using unencoded reserved characters.

All of these calls would be from a user's browser to my Jersey service. In
my testing I'm using Firefox 3.6.12(yes its hella old, but it's all they'll
give us at work for now).

Thanks,~Mike~