users@jersey.java.net

Re: [Jersey] problem with jsp Viewable not being evaluated

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 03 Dec 2009 10:24:53 +0100

Hi Gabriele,

I do not see anything obviously wrong with your configuration.

You might need to upgrade. Let me create a simple maven web project
and i will send a zip of that to the list.

Paul.

On Dec 2, 2009, at 6:48 PM, gabriele renzi wrote:

> Hi everyone,
>
> my problem seem similar to the one described here[1], but there is no
> final solution there so I'll try to rehash it, sorry :)
>
> Basically, my absolutely-specified Viewable gets loaded, but it does
> not seem to be evaluated as a jsp, it just ends up being rendered
> as-is.
>
> Looking at the Bookstore example I do not see anything configured
> specially to use jsp so I think it should be implicit, but, well, it
> does not work for me.
>
> My web.xml looks like
>
> <web-app>
> <display-name>Manager</display-name>
> <servlet>
> <servlet-name>Manager</servlet-name>
> <servlet-
> class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-
> class>
> <init-param>
> <param-name>com.sun.jersey.config.property.resourceConfigClass</
> param-name>
> <param-value>com.sun.jersey.api.core.PackagesResourceConfig</
> param-value>
> </init-param>
>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
> <param-value>my.package.servlet.rest</param-value>
> </init-param>
> <init-param> <!--unnecessary ATM-->
>
> <param-name>com.sun.jersey.config.feature.ImplicitViewables</param-
> name>
> <param-value>true</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>Manager</servlet-name>
> <url-pattern>/1/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
>
> My resource class looks like
>
> @Path("manager")
> @Produces({ "text/html", "application/xhtml+xml", "application/xml" })
> public class IndexManagementServlet {
> @GET
> @Path("count")
> public Viewable index() {
> System.out.println("actually called");
> return new Viewable("/count", aMap); //also tried with /count.jsp,
> no changes
> }
> }
>
> my count.jsp is simply
>
> <html>
> <body>
> # ${it}
> </body>
> </html>
>
>
>
> My configuration is: jersey 1.0.2 (will upgrade if needed), jetty 7,
> jsp-2.1.jar and jsp-api-2.1.jar in the CP,
> and I am running my webapp in testing mode via jetty's servlet runner
> with code like
>
> final Server server = new Server(SERVLET_PORT);
> final WebAppContext app = new WebAppContext("webapp", "/");
> server.setHandler(app);
> server.start();
>
> (which worked for other Jersey apps)
>
> After launch, if I access
> localhost/1/manager/count
> I can see the jsp gets loaded, but it does not seem to be evaluated as
> such, meaning I can see the literal
> # ${it}
> string in output
>
> is there something obvious I'm doing wrong? shall I upgrade jersey
> maybe ?
>
> Thanks in advance for any help.
>
> [1] http://n2.nabble.com/NewBee-to-Jersey-Viewable-Class-
> td3661511.html
>
> --
> blog en: http://www.riffraff.info
> blog it: http://riffraff.blogsome.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>