Hi,
I think the issue is because the Jersey servlet is consuming all
requests, including those to forward to JSPs.
Try configuring the ServletContainer as a filter and using one of the
following features:
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/container/servlet/ServletContainer.html
#PROPERTY_WEB_PAGE_CONTENT_REGEX
https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/spi/container/servlet/ServletContainer.html
#FEATURE_FILTER_FORWARD_ON_404
The other solution is to host the servlet at a distinct URL pattern,
say "/resources/*".
Paul.
On Oct 27, 2010, at 7:59 AM, Jared O'Connor wrote:
> Hi
>
> I'm currently developing a system containing embedded Jetty and a
> Jersey servlet. I'm using Maven and the project is to be packaged as
> a JAR. All my JSP files are sitting in the /resources/jsp/ folder
> (not /webapp/). Everything is working great, with the exception of
> JSPs.
>
> My server is created with the following code.
>
> ServletHolder holder = new ServletHolder(ServletContainer.class);
> holder
> .setInitParameter
> ("com.sun.jersey.config.property.resourceConfigClass",
> "com.sun.jersey.api.core.PackagesResourceConfig");
> holder.setInitParameter("com.sun.jersey.config.property.packages",
> "my.package.here");
>
> String jspDirectory =
> Application
> .class.getClassLoader().getResource("jsp/").toExternalForm();
> holder
> .setInitParameter
> ("com.sun.jersey.config.property.JSPTemplatesBasePath", jspDirectory);
>
> Server server = new Server(8080);
> Context context = new Context(server, "/", Context.SESSIONS);
> context.addServlet(holder, "/*");
> server.start();
>
> I then have various places I would like to pull up a JSP, as below.
>
> @GET
> @Produces("text/html")
> public Viewable getHtml()
> {
> return(new Viewable("/index", model));
> }
>
> I've tried playing around with TemplateProcessor, ViewProcessor and
> a few of the servlet context methods, but I cannot get JSPs to work.
> Below is the error I receive.
>
> java.io.IOException: The template name, /index, could not be
> resolved to a fully qualified template name
> at
> com
> .sun
> .jersey
> .server
> .impl
> .template
> .ViewableMessageBodyWriter.writeTo(ViewableMessageBodyWriter.java:79)
> ...
>
> If anyone is able to provide some guidance in this matter, it would
> be greatly appreciated.
>
> Kind regards
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>