You can use "explicit" jsp pages also, which makes things a bit more clear, I think.
The short answer is: in your resource method, return com.sun.jersey.api.view.Viewable instead of your JAXB type.
The Viewable instance in constructed with:
- your data object (maybe a JAXB type, maybe some arbitrary type), that can be referenced via ${it} context var within the jsp page
- path to your jsp page
See Paul's blog entry regarding this here:
http://blogs.sun.com/sandoz/entry/mvcj
Tyson
-----Original Message-----
From: Kevin Duffey [mailto:andjarnic_at_yahoo.com]
Sent: Fri 8/22/2008 10:12 PM
To: users_at_jersey.dev.java.net
Subject: Re: [Jersey] Using JSP for HTML representation
Hey,
I am guessing here.. but looking at the web.xml for that example:
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
<param-value>true</param-value>
</init-param>
Not sure if that helps it, but my guess is the response is somehow "redirected" back to the jsp page... based on the Redirect param and ImplicitViewables param above. I really don't see tho looking at it how each jsp page gets called, but another guess is the name of the jsp page is in the same path as that of the Resource... that is com\sun\jersey\samples\bookstore\resources seems to be the package names for the java classes, and the same "path" for the jsp pages.
Maybe you can mess around with that and see what happens.
----- Original Message ----
From: Daniel Larsson <daniel.j.larsson_at_gmail.com>
To: users_at_jersey.dev.java.net
Sent: Friday, August 22, 2008 6:25:44 PM
Subject: [Jersey] Using JSP for HTML representation
Hi,
The bookstore example shows how to use JSP pages for resources. How does jersey decide to use this page when returning the response? I'm returning an instance of a @XmlRootElement annotated class, and there's a provider in the jersey library that has a "*/*" producer, so I'm getting an XML document in response when doing a GET with Accept: text/html.
Is there a way to have my application return the JSP generated page instead?