users@jersey.java.net

Re: [Jersey] semicolon in path param

From: Trolly Rogers <trolly.s.rogers_at_gmail.com>
Date: Sat, 31 Jul 2010 11:49:35 -0400

Thanks for the info guys. With minimal effort we were able to eliminate the
usage of semicolon in item's {id}.

On Wed, Jul 28, 2010 at 4:39 AM, Paul Sandoz <Paul.Sandoz_at_oracle.com> wrote:

>
> On Jul 28, 2010, at 3:26 AM, Craig McClanahan wrote:
>
> On Tue, Jul 27, 2010 at 6:10 PM, trolly <trolly.s.rogers_at_gmail.com> wrote:
>
>>
>> Hi All - This probably has an obvious solution, but I just can't dig it
>> up. I
>> have a resource that has a path like this...
>>
>> /items/{id}
>>
>> The id path param is a String, and can contain semicolon. It appears that
>> path params passed in with semicolons are split, and only the first token
>> is
>> being returned.
>
>
> This is because, according to the syntax specification for URLs[1], a
> semicolon is used to delimit path parameters in a path segment. If you
> really really want to use semicolons, you will need to URL encode them.
>
>
> ... also JAX-RS, by default, strips them out for matching, and refers to
> them as matrix parameters which can be accessed using the @MatrixParam [1]
> annotation.
>
> In Jersey there is a feature to not strip out the matrix parameters, see:
>
>
> https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ResourceConfig.html
> #FEATURE_MATCH_MATRIX_PARAMS
>
> There is an error in the JavaDoc (i have just fixed) and it should read:
>
> If true matrix parameters (if present) in the request URI path component
> will *not* be ignored when matching the path to URI
> templates declared by resource classes.
>
> Paul.
>
> [1]
> https://jsr311.dev.java.net/nonav/releases/1.1/javax/ws/rs/MatrixParam.html
>
> Better would be to use some sort of identifier that doesn't use any
> characters reserved by the specification (like '/' and ':'), but that's not
> always possible.
>
> Craig
>
> [1] http://www.ietf.org/rfc/rfc2396.txt
>
>
>