users@jsr311.java.net

JAX-RS: _at_Path encode parameter is needed

From: Manger, James H <James.H.Manger_at_team.telstra.com>
Date: Mon, 14 Jul 2008 09:41:57 +1000

I was wrong a fortnight ago when I though any sensible @Path value with encode=false could be re-written with encode=true.
A @Path value does need encode=false when it includes:
* a %-escaped <reserved> character (eg a ‘/’ that is NOT a path segment separator); or
* a %-escaped ‘{‘ or ‘}’ (so it is not misinterpreted as a {name} placeholder).

Example: @Path(value=”/math/pi=22%2F7”, encode=false)


When encode=true I assume ‘?’, ‘#’ and ‘%’ characters in a @Path value are encoded (as %3F, %23 and %25) as they are not allowed (alone) in a path, despite being “valid URI characters”. Instead of talking about “valid URI characters”, the Path#encode javadoc could say:
  “If true, any percent characters or characters that are not valid in a URI path will be automatically encoded.”


James Manger