1

Long story short: I get this as output

<html><body><c:if test="false">
   strange
</c:if></body></html>

when using JSTL with an embedded Jetty.

Long story long:

my directory structure:

web-example+
           |_src+
           |     \_main+
           |            \_webapp+
           |                    |_index.jspx
           |                    |_WEB-INF+
           |                              \_web.xml
            \_pom.xml

my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebExample"
    version="2.5">

</web-app>

my index.jspx:

<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:parts="urn:jsptagdir:/WEB-INF/tags">

<jsp:directive.page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />

<html><body>
    <c:if test="${'1' == true}">
        strange
    </c:if>
</body></html>

</jsp:root>

and, finally, my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>web-example</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.simplericity.jettyconsole</groupId>
            <artifactId>jetty-console-maven-plugin</artifactId>
            <version>1.47</version>
            <executions>
                <execution>
                    <goals>
                        <goal>createconsole</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-http</artifactId>
        <version>8.1.4.v20120524</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>8.1.4.v20120524</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-jsp</artifactId>
        <version>8.1.4.v20120524</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>8.1.4.v20120524</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
        <version>8.1.4.v20120524</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
</dependencies>
</project>

I assume that this is a problem specific to the jetty-console-maven-plugin, since everything works fine when I start the webapp within Eclipse (using a small Java class that starts Jetty I did not include here).

I have looked at other answers, e.g., from cannot load JSTL taglib within embedded Jetty server and JSTL not parsed in a JSP page running on an embedded Jetty instance and thereby changed quite some things which helped me to get so far, e.g., I updated the jetty-console-maven-plugin in order to not have old servlet specification code, I removed jsp and servlet JARs from /usr/share/java, I updated the XML specs of the web.xml and index.jspx, and so on but it did not help.

Does anybody have an idea what is going wrong?

Community
  • 1
  • 1
Robert
  • 872
  • 3
  • 10
  • 15
  • I wonder if I am missing some dependency, e.g., the servlet or the JSTL API? I tried to add something in that direction to the POM (e.g., javax.servlet-api and jstl and also the jstl-impl from org.glassfish.web, see http://stackoverflow.com/questions/6094329/tomcat-7-and-jstl) but that did not help. – Robert Dec 11 '12 at 09:42

1 Answers1

1

I'm the creator of JettyConsole, and I failed reproducing the problem you described using your provided code samples.

I recreated your directory structure with the content of the files you provided, ran a clean Maven install and ran java -jar on the resulting jetty-console war.

http://localhost:8080/index.jspx 

rendered as expected, with the JSLT code properly parsed.

http://localhost:8080/

rendered a 403 forbidden, probably because index.jspx is not on your welcome-file-list and Jetty wants to hide the JSP source code.

I'd say this question should be improved to reproduce the issue, or closed.

eirbjo
  • 11
  • 2