users@jersey.java.net

[Jersey] Re: Putting simple web interface to jersey REST endpoint

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Mon, 19 Dec 2011 09:13:16 -0500

Hi ManiKanta,

Thank you for introducing me to the Viewable
<http://jersey.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/view/Viewable.html>
class in jersey. It will be useful in my solution. However, your post
does not seem to address the need I have as follows:

    * Keep a single set of resource methods that return XML response
    * Allow XML response to be algorithmically mapped to HTML using some
      custom mapping class(es)

I had mentioned that my current resource methods somehow support
"application/json" automatically using the
com.sun.jersey:jersey-json:jar:1.10:compile dependency even though the
method just returns an XML response. Clearly the jersey-json adds
support for marshalling/unmarshalling json from XML. I want to do
similar by marshalling responses to HTML.

I am just not familiar enough with jersey API and framework as to how to
do that. Given more time I will figure it out but I was hoping that
someone could provide high level steps of how to do that. Thank in advance.

On 12/19/2011 02:02 AM, ManiKanta G wrote:
> you could do that using Viewable
> <http://jersey.java.net/nonav/apidocs/1.1.0-ea/jersey/com/sun/jersey/api/view/Viewable.html> we
> are serving the html response for html mime type by having a generic
> resource method in super class
>
> see
> http://blog.docuverse.com/2009/08/04/using-jsp-with-jersey-jax-rs-implementation/
> http://stackoverflow.com/questions/3361877/jersey-viewable-with-status-code
>
>
> ManiKanta G
> twitter.com/ManiKantaG <http://twitter.com/ManiKantaG>
>
>
> On Sat, Dec 17, 2011 at 11:39 PM, Farrukh Najmi
> <farrukh_at_wellfleetsoftware.com <mailto:farrukh_at_wellfleetsoftware.com>>
> wrote:
>
> Hi Guys,
>
> My jersey based REST endpoint serves resources in their native XML
> format when default or in JSON format when application/json
> mediatype is specified. Things are working pretty well.
>
> I would like to add a simple Web interface for human access to my
> REST endpoint and was thinking that I could add support for
> mediatype text/html in my endpoints resource methods via @Produces.
>
> What I am not sure of what is the best way to do this in jersey.
> Jersey support JSON format without any help from my code so I
> assume there is a global filter somewhere to transform XML to
> JSON. I am looking to do similar with HTML. Thanks for any
> guidance on this.
>

-- 
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com