Re: [Jersey] howto RESTfully relate resources?

From: <>
Date: Tue, 9 Feb 2010 12:15:30 -0600

Sorry for replying to my own post here, but I just had this idea related
to my previous post that I think is worth sharing.

        public Response relateFoo(@QueryParam("fooUrl") FooResource
aFooResource) {
                // the jersey container will process the fooUrl parameter
in order to come up with the FooResource parameter

I think this would be a nice addition to jersey and in line with the
HATEOAS ideas floating around. If resources are identified by uris, then
we should be able to consume a uri and map it back to a resource.

Does this make sense? Would it be hard to do?


02/08/2010 08:27 AM
Please respond to


Re: [Jersey] howto RESTfully relate resources?

Passing the parameter is not the problem. I want to process that parameter
URI the same way the jersey container does and get a resource object out
of it.
I want to process all the rules except the last one for HTTP method and
the creation of the representation. I think all the code to do this is
already in the container,
just need to find out how to get to it...

Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Sent by: Paul.Sandoz_at_Sun.COM
02/08/2010 04:38 AM

Please respond to


Re: [Jersey] howto RESTfully relate resources?


Do you want to pass a URI as the value of a query parameter?

For example:


You can do:

  public XXX get(@QueryParam("uri") URI uri) { ... }

because URI contains a constructor that has a single string parameter.

Note that you need to make sure the client constructors the URI with the
embedded URI correctly such that the embedded URI is correctly encoded,
for example if the embedded URI has query parameters the approach
characters need to be percent encoded.


On Feb 5, 2010, at 9:00 PM, wrote:

Imagine a scenario where on a page a user needs to relate various
resources together - in its simplest form a copy/paste scenario.
The resource being pasted is identified with a URI. Now a request is made
to the service containing that URI of the resource being
related to the receving resource.... How do I translate that URI to the
actual to be related resource?

The jersey container already knows how to do this when it receives a
request on that resource....
Do I get access to that part of the container code so I can determine the
resource identified by a URI received as data ,
for example as a @QueryParam?

Frank Sauer
Principal Architect
DST Health Solutions
2500 Corporate Drive
Birmingham, AL 35242
(205)437-5204 (Office) (Direct)
(205)568-4684 (Cell)
It is impossible to sharpen a pencil with a blunt axe. It is equally vain
to try to do it with ten blunt axes instead -- Edsger W. Dijkstra

----------------------------------------- Please consider the environment
before printing this email and any attachments. This e-mail and any
attachments are intended only for the individual or company to which it is
addressed and may contain information which is privileged, confidential
and prohibited from disclosure or unauthorized use under applicable law.
If you are not the intended recipient of this e-mail, you are hereby
notified that any use, dissemination, or copying of this e-mail or the
information contained in this e-mail is strictly prohibited by the sender.
If you have received this transmission in error, please return the
material received to the sender and delete all copies from your system.