users@jersey.java.net

Re: [Jersey] Re: Spring Annotation injected resources with JSP views

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 27 May 2009 06:22:57 -0700

On May 27, 2009, at 5:39 AM, rossjduncan_at_gmail.com wrote:

> Hi Paul,
>
> Thanks very much for your help with this, and especially for going
> to the trouble of preparing the modified bookstore code!
>
> We have had a few maven/http connectivity issues from our dev
> environment this week that have hamperred progress testing this, but
> I did manage to get the code you attached on Monday running (just
> once!) earlier in the week - this being enough to demonstrate the
> two concepts (spring annotations, and implicit JSP) working together.
>

Great.


> Im not sure I understand all the details of why the filter is more
> appropriate in this case (other than that it works!), but I am
> really happy to see this much working.
>

OK, i suggest you experiment using servlet instead of filter with URL
patterns of say "/" and "/resources/*". I do not know why the former
works but not "/*", i have only tested on GF and Tomcat so do not know
if this behavior manifests itself on other app servers.


> More than likely we will have more questions about Jersey, but
> thanks for the quick and helpful response.
>

OK! just ask away :-)

Paul.

> Cheers,
> Ross
>
>
> > Content-type: multipart/mixed;
> boundary="Boundary_(ID_zlno26x53kbNnAGLvAeBsw)"
> > Date: Mon, 25 May 2009 07:22:13 +0200
> > From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> > Subject: [Jersey] Spring Annotation injected resources with JSP
> views
> >
> >
> > Hi Ross,
> >
> > See attached for a modified Bookstore sample that uses Spring.
> >
> > When using GF, Jersey with Servlet and the JSP view support it will
> > only work with URL patterns of the form "/" or "/<something>/*", and
> > will not work with a URL pattern of "/*", and a 404 will be returned
> > (even though there is no error forwarding to the JSP). I am not sure
> > if that behavior is the same for other app servers.
> >
> > So, it is recommended that if you want to use JSP view support
> with a
> > URL pattern of "/*" that you utilize a filter.
> >
> > Hope this helps,
> > Paul.
> >
> >
> >
> >
> >
> > On May 23, 2009, at 10:09 AM, Ross Duncan wrote:
> >
> > > Hi guys,
> > >
> > > Great to be joining the mailing list.
> > >
> > > I have been experimenting with Jersey for the past couple of
> weeks,
> > > and would like to share a challenge I am facing.
> > >
> > > I am looking to build a Spring based application with both human
> web
> > > and machine web clients. I want to be able to, as far as possible,
> > > serve HTML pages as well as JSON (or some other machine friendly
> > > representation) out of the same codebase.
> > >
> > > REST looks like a good fit for this because the the same Resource
> > > could simply have different Representations for humans and
> machines.
> > > Jersey looks like a good fit because there are already examples
> that
> > > demonstrate the implicit binding of JSP views to Resources
> > > (Bookstore sample), and the annotated Spring integration (spring-
> > > annotations sample).
> > >
> > > The trouble for me is, I havent so far managed to get both
> concepts
> > > working at the same time in the same application. I have tried
> > > various ways of combining the two samples, but I always end up
> with
> > > a 404 when accessing the Resource URLS from the web browser. Im
> > > guessing I just need to strike upon the right way of configuring
> > > web.xml, but the two samples take two different approaches here.
> > > Bookstore sets up Jersey using a filter, and Annotated-Spring
> uses a
> > > Servlet. I have tried taking the configuration options used
> against
> > > the filter in Bookstore and adding them to the servlet's
> > > configuration in Annotated-Spring, but no joy.
> > >
> > > Is it clear what I am trying to do? If so, is it possible with the
> > > current version of Jersey?
> > >
> > > Any help would be much appreciated!
> > >
> > > Thanks,
> > > Ross