users@jersey.java.net

Re: [Jersey] Call another Resource with some other values

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 04 Jan 2010 13:39:08 +0100

On Jan 4, 2010, at 12:25 PM, Cemo Koc wrote:

>
>
> Hi Paul,
>
> Thanks for your reply.
>
> Is it possible to call a resource in another resource such a
> *String* ?
>
> URL="pathA/{ad}"
>

No, it is not possible to get a resource instance given a URI
template. It may be possible to support obtaining a resource instance
given a URI path. But the general problem is you want to make a psuedo
HTTP request and return the output of a GET request from a different
URI to that of a POST request.

I think the application is in the best position to decide on
validation error what to do, and the framework cannot know what the
value for {ad} should be. And, in any validation error response you
should indicate what was wrong, thus i would expect the response
entity returned from the invalid POST request to be different from the
response entity returned from the GET request (although there may be
some similar content e.g. the form).

I think there are may be a number ways to consider this:

1) Return JSON and/or XML from the POST one success or validation
error. Any HTML will use AJAX to perform the POST and
      thus the URL where the form was obtained will not change in the
browser.

2) The POST and GET share some code and it is not necessary for the
POST to defer to GET directly.

3) Use views, the POST view can inherit or include the GET view . It
might, in this respect, be appropriate
      to declare the validation error view to utilize in the
@ValidationEnabled annotation.

Paul.