dev@jsr311.java.net

URI Escaping and Unescaping

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Wed, 20 Jun 2007 14:57:36 -0400

Julian found a bug in the RI[1] and the discussion brings up an
interesting question about expectations wrt escaping and unescaping
in the API. E.g.

Given the resource class:

@UriTemplate("hello/{name}")
public class Hello {

   @HttpMethod(GET)
   public String sayHello(@UriParam("name") String name) {
     return "Hello "+name;
   }
}

and a GET on hello/x%20y, what should the value of the name parameter
be: "x%20y" or "x y" ?

My working assumption, which isn't reflected in the Javadoc, is that
the developer would work with unescaped values for @UriParam,
@QueryParam and @MatrixParam so the value of name would be "x y".

A related question is whether the @UriTemplate value should be in
escaped or unescaped form. In this case I'd say that it should be in
escaped form, i.e. a developer would have to write @UriTemplate("hello
%20world") rather than @UriTemplate("hello world").

Does the above match others expectations ?

Thanks,
Marc.

[1] https://jersey.dev.java.net/servlets/ReadMsg?list=dev&msgNo=1
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.