users@jersey.java.net

Re: [Jersey] Jsp is not evaluated

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 30 Apr 2010 10:51:06 +0200

Hi Franz,

I think the version defined in the web-app defines what is supported
in the web container.

Thus i suspect for 2.3 based web-apps (which are rather old) the
feature of passing variables from the request dispatcher to the JSP
does not work. It does for 2.4 and 2.5-based webapps.

Can you specify the version of the web app, or EE, when usng the maven
web archetype? I did a quick search but it is hard to find any
documentation on this.

Jersey does have a web archetype:

   GroupId: com.sun.jersey.archetypes
   ArtifactId: jersey-quickstart-webapp
   Version: 1.1.5.1
   Repository: http://download.java.net/maven/2/

which will generate a 2.5 version web app.

BTW i do not know why maven defaults to such an old version. It is the
same for Java compilation.

Paul.

On Apr 29, 2010, at 4:45 PM, Franz Wong wrote:

> Hi,
>
> I have a @GET method returning Viewable. As I know, I can use ${it}
> to get the model object. However, the jsp cannot evaluate it and it
> outputs the text "${it}" instead.
>
> I have googled for solution and I found a thread [1] talking about
> it. However, there is no final solution.
>
> I tried the small example in [1] provided by Paul Sandoz. After some
> time of investigation, I found something interesting. I don't know
> whether it is a known issue yet.
>
> maven-archetype-webapp generates a web.xml with the following header.
>
> <!DOCTYPE web-app PUBLIC
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd" >
>
> <web-app>
>
> The header of web.xml I found in Paul's example is the following.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
> ">
>
> If I use Paul's one, my Jsp is evaluated successfully. This is not
> what the behavior I expected although it works now anyway.
>
> Regards,
> Franz
>
> [1] http://jersey.576304.n2.nabble.com/problem-with-jsp-Viewable-not-being-evaluated-td4101170.html