Reputation: 3736
I'm trying to test a simple webapp to work on a servlet container that only supports servlet api 2.3. Unfortunately, I don't have access to the 2.3 container yet so I tried testing on a recent version of tomcat.
I have the following setup:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
In one of my maven dependencies, I added the jstl library so it is now on my classpath:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
Unfortunately, my EL doesn't work, they just get rendered as is. E.g.: ${2+2} is not shown as "4". Here's a snippet of my jsp page:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<h2>Hello World</h2>
<c:out value="${2+2}"/>
</body>
</html>
So I assume this because I have mismatch between my web.xml declaration (saying it's 2.3) but my actual servlet container (tomcat) wants to use 3.0 with jstl 1.2. If I really wanted to make it work, I could update my web.xml to also use version 3.0. However, this would not work on the (other) servlet-container that is 2.3. So my question is, how can I test my 2.3 webapp, Is there an older version of tomcat that uses 2.3 aswell? Or is servlet 3.0 backwards compatible and did I misconfigure something?
Note: the actual loading of the pages and the webapp in general works fine, it's only the EL (${something}) that don't evaluate.
Upvotes: 1
Views: 1358
Reputation: 2614
If you are using servlet version 2.3 or earlier than 2.3 then EL are by default disabled so you have to enable it means by default it is true as :
isELIgnored ="true"
you have to make it false.
but if you are useing later version of servlet than 2.3 then it is enabled by default means
isELIgnored ="false"
you can enable or desable by
<%@ page isELIgnored ="true|false" %>
at a time only one value you can give true or false
.If it is true, EL expressions are ignored when they appear in static text or tag attributes. If it is false, EL expressions are evaluated by the container.
Upvotes: 4
Reputation: 532
First check do you have correct version of jstl.jar
and standard.jar
WEB-INF/lib folder.
Upvotes: 0
Reputation: 3431
Use isELIgnored
in page tag
<%@ page language="java"
contentType="text/html;
charset=ISO-8859-1" pageEncoding="ISO-8859-1"
isELIgnored="false"%>
Upvotes: 1