Hi Ara,
On Sep 27, 2009, at 9:23 PM, Ara Vartanian wrote:
> 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
>
Yes.
> And I've also read in places like:
>
> http://www.theamazingrando.com/blog/?p=107
>
> that clients should not be asked to create URLs.
>
They can as long as the representation produced by the server tells
the client how they should be constructed. That is essentially what an
HTML form can do.
> 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.
>
>
There have been a number of discussions and applied solutions on the
users list, i recommend searching:
http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users
I have not had time to look fully into this yet. It is something we
must look at after we release Jersey for Java EE 6.
Nothing completely definitive has yet to emerge but i think there are
some aspects that are starting to emerge. The main one being the
ability to annotate model representation classes with typed link
information, so that instances of those classes are post processed to
embed links. Such information would include the URL but may also
include say a "rel" attribute defining the type of the link.
IMHO i think relative links in representations only make sense if
there is a base URI in the representation from which those relative
links can be resolved (e.g. using XML base, but not all XML processors
may support that).
Paul.