users@jersey.java.net

Hyperlinks in REST responses

From: Ara Vartanian <ara_vartanian_at_yahoo.com>
Date: Sun, 27 Sep 2009 12:23:11 -0700 (PDT)

I've read in many places that one of the benefits of REST web services is navigability between resources using hyperlinks:

http://www.xfront.com/REST-Web-Services.html

And I've also read in places like:

http://www.theamazingrando.com/blog/?p=107

that clients should not be asked to create URLs.

To that end, I was wondering what the Jersey design pattern is for including hyperlinks in responses. There seem to be a few challenges to me:

(1) Marshaling Java POJOs themselves would not include such hyperlink "fields".
(2) The "base URL" is something that might change from deployment to deployment, and yet relative URLs present their own problems. Non-browser clients still would have to concatenate base and relative paths. And even browsers won't make much use of relative links embedded in XML.