users@jersey.java.net

Re: [Jersey] path template variable

From: Mehdi Ben Haj Abbes <mehdi.abbes_at_gmail.com>
Date: Thu, 18 Dec 2008 01:50:15 +0100

On Wed, Dec 17, 2008 at 7:46 PM, Craig McClanahan
<Craig.McClanahan_at_sun.com>wrote:

> Mehdi Ben Haj Abbes wrote:
>
>> Hi,
>>
>> Please I want to know how can I specify a path template variable so it can
>> accept a path (
>>
>> for example : if I make a request to bseURI/machin/containers/smth and in
>> machinResource I have @Path("{container}"), @PathParam("container") will
>> return containers/smth
>>
>> As you have undoubtedly discovered, the "container" parameter in this
> case will contain "containers". The typical pattern in JAX-RS is to use a
> sub-resource class to match the next element, or a second path on an
> individual method:
>
> I do not want to specify @Path as @Path("{part1}/{part2}"),
>>
> Just out of curiousity, why do you not want to do this? You can always
> concatenate the parts back together if you really need "containers/smith"
> inside the application.


>
> Personally, I would recommend splitting things up:
>
> @Path("{container}")
> public class MyResource {
> ...
> @Path("{name}"
> @GET
> public Response myGetMethod(@PathParam("container") String container,
> @PathParam("name") String name) {
> String combo = container + "/" + name; // If you really need it
> combined
> ...
> }

I thought of this solution but it doesn't answer to my needs

 In fact I want to let the user free to submit any path template I do not
want him to be restricted to submit a path with two parts like
@Path("{part1}/{part2}")
but to allow him any pattern of this
form @Path("{part1}/{part2}/.../{partn}/")

thanks

>
> Craig
>
> I tried to submit an encoded URI with %2F but I get 400 status code
>> thanks and regards
>> --
>> Mehdi BEN HAJ ABBES
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>


-- 
Mehdi BEN HAJ ABBES