We are trying to move our Java web application from a Tomcat 5.5 server to a more modern Tomcat 6.0.24 one, but we are having some problems with JSP EL.
The expressions placed within XML tag files are not recognized by the server, that simply renders them as text (just as in the following example). Any ideas why?
<object id="${id}"
classid="java:${code}.class"
type="application/x-java-applet;version=1.5"
archive="${archive}" codebase="${codebase}"
height="${height}" width="${width}" >
<param name="code" value="${code}" />
<param name="codebase" value="${codebase}" />
<param name="archive" value="${archive}" />
<param name="type" value="application/x-java-applet;version=1.5"/>
<param name="mayscript" value="true" />
<param name="cache_archive" value="wetorrent.jar,weupnp.jar" />
<param name="cache_version" value="0.0.0.17,0.0.0.17" />
<strong>
<span style="cursor: pointer" onclick="window.open('http://www.java.com/','_blank','toolbar=1,scrollbars=1,location=1,statusbar=1,menubar=1,resizable=1');">
This browser does not have a Java Plug-in.<br />
Get the latest Java Plug-in here.</span>
</strong>
</object>
The weird thing is that in the JSPs that include the tag EL expression work perfectly.
I even tried setting the isELIgnored="false"
attribute within the .tag file, but I got this error:
Tag directive: illegal to have multiple occurrences of isELIgnored with different values (old: true, new: false)
Where does the old (true) value come from? We never specified that.
Some o开发者_运维百科ther info:
The taglib is always included (in .jsp and .tag files) using <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
We put standard.jar
and jstl.jar
in the server's lib/
directory.
The web.xml
starts with the following line:
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
Tomcat 6.0 is a Servlet 2.5 & JSP 2.1 container. First, try using the following <web-app>
start tag:
<web-app 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"
version="2.5">
Also, if you're using JSTL, don't install the JARs in Tomcat's lib
dir, keep them in the app's WEB-INF\lib
dir. By the way, as of JSP 2.0, the EL is part of JSP proper so JSTL is not required for its evaluation.
Since it works with JSPs but not tags, you could also check the .tld, if you have the jsp-version element that could be the reason:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" version="2.0">
<tlib-version>2.0</tlib-version>
<jsp-version>1.2</jsp-version>
simply remove the jsp-version element.
This is a bug in Tomcat. I filed a bug report here: https://issues.apache.org/bugzilla/show_bug.cgi?id=52931
To workaround it, just leave the attribute "jspversion" in blank, like @Ceren suggested.
Are you sure you have the JSTL 1.2 jars? You need to have that version to recognise ${foo}
without the <c:out/>
I think.
精彩评论