On Mar 4, 2009, at 9:07 PM, Marc Hadley wrote:
> On Mar 4, 2009, at 2:54 PM, John Huang wrote:
>>
>> We have some services implemented using Jersey. And these services
>> are running in the same app server as our existing web application.
>> Is it possible to forward or include the resource from our existing
>> web application using servlet dispatcher instead of using the
>> Jersey client api?
>>
> You can forward by injecting the HttpServletRequest and using that
> in your code as normal. Including is trickier since typically JAX-RS
> only writes the response after the resource method returns. You
> could conceivably call RequestDispatcher.include from a
> MessageBodyWriter.writeTo but I don't know how well that would work
> out in practice.
>
This should be possible, although i do not know how this will behave
if you need to modify request parameters, such as header or query
parameters.
The above is what Jersey uses to forward to JSPs using the Viewable
class [*] and a ViewableMessageBodyWriter that defers to a
JSPTemplateProcessor.
Paul.
[*] For more details see here:
http://blogs.sun.com/sandoz/entry/mvcj
Note that in the process of improving the JavaDocs so that what is in
the blog entry linked above will be present in the package section of
"com.sun.jersey.api.view".