users@jersey.java.net

Re: [Jersey] How to capture a possibly variable number of PathParams ?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 25 Jan 2010 11:30:06 +0100

On Jan 23, 2010, at 2:43 PM, Yoryos wrote:

> Did you try regular expressions? Try @Path("{rest: .+}") instead of
> @Path("rest").
>

In this case @Path("{rest}") should work in the examples given because
there is only one path segment present.

What web container are you using?

Some web containers replace '%2F' with '/' before it reaches the
servlet layer but they support an option not to do this. For example
see:

   http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users++Escaping+a+PathParam+slash#query
:list%3Anet.java.dev.jersey.users%20%20Escaping%20a%20PathParam%20slash
+page:1+mid:fw2hbcqa3s55jegw+state:results


The path parameters can support a sequence characters that are UTF-8
encoded into a sequence of octets that are then encoded into a
sequence of ASCII or percent encoded values compatible with the URI
specification. Which is a long winded way of saying, yes Japanese
characters are supported as long as UTF-8 is utilized to encode those
characters.

Paul.


> On Fri, Jan 22, 2010 at 06:13, Gavin Bong <malaisien_at_gmail.com> wrote:
> Hello,
>
> I am currently using Jersey 1.1.4
>
> I have a Resource that roughly looks like the following:
>
> @Path( "/sys/{language}" )
> public class SystemResource
> {
> @GET @Path( "rest" )
> public Response doGet( @PathParam( "rest" ) String rest )
> {
> .... snipped ...
> }
> }
>
> What I've found are:
> a) Each placeholder for a PathParam is a mandatory field in the URL
> b) Each PathParam cannot accept an encoded string e.g. "holy%2Fcow"
>
> What I want to do is to be able to support urls like:-
>
> 1) http://server/rs/sys/EN/holy%2Fcow
> 2) http://server/rs/sys/EN/obama%2Ffacing%2Fdemons
>
> Invoking (1) and (2) returns a 400 Bad Request.
>
> An extra question: can the path params support chinese characters ?
>
> --
> Sincères salutations,
>
> Gavin Bong
>
> Rien ne sert d'être vivant, s'il faut qu'on travaille - André Breton
> If you do things well, do them better. Be daring, be first be
> different, be just. - Anita Roddick
> http://amour.zaadz.com/blog
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>