Hello all,
I'm trying to make jersey be able to handle included requests. That means
that having a jsp to be able to include a uri that maps to a resource class.
Of course the resource class should be able to produce html.
I'm using the jersey filter. So the first thing I've done was to let the
Servlet container use the jersey filter not only for the actual requests but
also for the forwarding and included ones. This can be done by adding the
following to the mapping of the filter at web.xml:
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
This didn't work out of the box. So I had to take a look at the source in
order to have a better view of what is going on. Looking at the source of
jersey, I found that ServletContainer class does not handle included
requests at all. So I had also to fix that too. I've posted the code on a
previous email and also created an issue (
https://jersey.dev.java.net/issues/show_bug.cgi?id=432) with a maven project
with a working solution.
A working solution means that you can include a resource class with in jsp
and get html that you would have calling only the uri that maps to the
included class.
With a modified filter you will be able to just include resource classes
without any model as jersey binds the model always to 'it' at the request
scope. To overcome this I had to also modify a little bit the default
default jsptemplate and instead of binding the model to 'it', bind it to
something like '[ResourceClass.getClass().getSimpleName()]Model'
The above solution does not require to change Jersey's sources and works ok
but it is not the best one. I mean the user should be able to define the
name of the model at the request scope if he wants to and it would be nice
to be able to have an annotation for methods that should return only results
of type Viewable and it will be called only when the resource is about to be
included.
This is where I would like some help. Can someone explain the exact
procedure of serving a Resource class with a Viewable because I'm pretty
lost when tried to read the source. At least from where should I start
reading.
I hope I described ok the whole situation!
Yoryos