participate


JavaServer Pages (JSP) and JSTL - Couldn't Enable Expression language in JSP1.2
<<   Back to Forum  |   Give us Feedback
This topic has 11 replies on 1 page.
karthikraja_in
Posts:2
Registered: 2/23/01
Couldn't Enable Expression language in JSP1.2   
Apr 7, 2003 11:02 PM

 
Hi All,
i wanted to use expression language (EL) in my jsp page. But the expression language code is not getting evaluated. For example
for the following code
<jsp:root version="2.0">
<jsp:declaration>String s="Test String">
<jsp:text>This is a ${s}</jsp:text>
</jsp:root>
The output is "This is a ${s}". The EL ${s} is not being evaluated.

I am using Tomcat 4.1.24, which implements JSP 1.2 spec.
In JSP 1.2 specification i found that EL can be enabled by adding the following code under the element <web-app> in the web.xml file
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
<jsp-config>

but on adding this code in web.xml file tomcat generates parse error stating that "<jsp-config>" element not found. Now the problem is the dtd file (web-app_2_3.dtd) which is refered by web.xml is not having the element <jsp-config> or <jsp-property-group> or <el-enabled>

IF SOMEONE HAVE FOUND SOME SOLUTION FOR THIS KIND OF PROBLEM PLS HELP ME

Thanx,
Karthikraj.
 
oroussea
Posts:1
Registered: 4/15/03
Re: Couldn't Enable Expression language in JSP1.2   
Apr 15, 2003 8:27 AM (reply 1 of 11)  (In reply to original post )

 
Hi All,
i wanted to use expression language (EL) in my jsp
page. But the expression language code is not getting
evaluated. For example
for the following code
<jsp:root version="2.0">
<jsp:declaration>String s="Test String">
<jsp:text>This is a ${s}</jsp:text>
</jsp:root>
The output is "This is a ${s}". The EL ${s} is not
being evaluated.

I am having the same problem...


I am using Tomcat 4.1.24, which implements JSP 1.2
spec.
In JSP 1.2 specification i found that EL can be
enabled by adding the following code under the element
<web-app> in the web.xml file
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
<jsp-config>

your la tag should be </jsp-config> i believe
im going to give this a try...

but on adding this code in web.xml file tomcat
generates parse error stating that "<jsp-config>"
element not found. Now the problem is the dtd file
(web-app_2_3.dtd) which is refered by web.xml is not
having the element <jsp-config> or
<jsp-property-group> or <el-enabled>

IF SOMEONE HAVE FOUND SOME SOLUTION FOR THIS KIND OF
PROBLEM PLS HELP ME

Thanx,
Karthikraj.
 
jwcyre
Posts:24
Registered: 8/30/01
Re: Couldn't Enable Expression language in JSP1.2   
Apr 8, 2004 11:29 AM (reply 2 of 11)  (In reply to #1 )

 
I had the same problem using the <jsp-config> tag. When I inserted the tag in the web.xml. It not only caused validation errors against http://java.sun.com/dtd/web-app_2_3.dtd but it caused errors in my web site which uses Struts 1.1.

Solution

Use the Page Directive isELIgnored and set it to false
<%@ page isELIgnored="false" %>
instead of using the <jsp-config> tag in the web.xml

Reference
JavaServer Pages 2.0 Specification page I-88
Table JSP.3-1
http://jcp.org/aboutJava/communityprocess/final/jsr152/
 
evnafets
Posts:10,694
Registered: 4/29/03
Re: Couldn't Enable Expression language in JSP1.2   
Apr 10, 2004 8:17 AM (reply 3 of 11)  (In reply to original post )

 
The EL is only added to the page in general as part of the JSP2.0 spec. Currently that means Tomcat 5.
For JSP1.2 containers use JSTL 1.0 For JSP2.0 containers use JSTL 1.1

In order to use the EL statements in JSP1.2 containers, you need to use it as an attribute of a c:out tag. The JSTL tag provides the EL translation engine. That is why JSTL1.0 provides both standard and RT versions, so you can decide whether to use EL or scriptlet expressions in your pages.

In JSP2.0 the EL translation is incorporated into the tomcat engine, and so it can be used straight on a page

In short you need to do something like this:
<c:set var="s" value="S"/>
<c:out value="${s}"/>

Note also that variables declared in your code like "String s" are not visible to the EL.
The EL variable space is the attribute space: pageContext, requestContext, sessionContext and applicationContext. So you need to set an attribute in one of these contexts in order for EL to find it.
Doing a jsp:useBean tag declares a bean both as a java variable and am attribute, so it can be used in both scriptlet and EL code.

Good luck,
evnafets
 
evnafets
Posts:10,694
Registered: 4/29/03
Re: Couldn't Enable Expression language in JSP1.2   
Apr 10, 2004 8:21 AM (reply 4 of 11)  (In reply to #3 )

 
In JSP 1.2 specification i found that EL can be enabled by adding the following code under the element...

Nope thats the JSP2.0 spec that you are reading.
And that only applies if the version of your web.xml file is not 2.4. If the declaration at the top of your xml file specifies as version 2.3, then for backwards compatibility it disables EL evaluation, unless you include that page directive explicitly on a page. If web.xml is up to date, then EL will be processed as normal.

Regardless, this only applies to JSP2.0 containers - Tomcat 5 - and not less.
 
aberglas
Posts:20
Registered: 16/05/01
Re: Couldn't Enable Expression language in JSP1.2   
Jul 24, 2006 12:51 AM (reply 5 of 11)  (In reply to #4 )

 
Make sure that you actually specify the version= for tomcat.

I just inserted an empty <web-app> tag in order to add some tag libs, expecting Tomcat to default to its conf/web.xml. Not so.

This was in amongst some other changes and cost me several hours of stuffing about. Bergsten does not mention that you have to enable JSTL!

Anthony
 
shruthi04
Posts:66
Registered: 7/17/06
Re: Couldn't Enable Expression language in JSP1.2   
Jul 24, 2006 1:28 AM (reply 6 of 11)  (In reply to #2 )

 
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:display="urn:jsptld:http://displaytag.sf.net/el" xmlns:c="urn:jsptld:http://java.sun.com/jstl/core">
<jsp:directive.page contentType="text/html; charset=UTF-8" isELIgnored="false"/>

For the above if i add isELIgnored="false" am getting following..
could no process the requestorg.apache.jasper.JasperException: /web/viewdata.jsp(16,40) According to TLD or attribute directive in tag file, attribute items does not accept any expressions
 
evnafets
Posts:10,694
Registered: 4/29/03
Re: Couldn't Enable Expression language in JSP1.2   
Jul 24, 2006 2:23 PM (reply 7 of 11)  (In reply to #6 )

 
You have a conflict in your page.

You are specifying JSP version1.2 in the <jsp:root> tag
You are then using a directive which only applies to JSP2.0 (isELIgnored)

So which is it? Are you writing for JSP1.2 or JSP2.0?
If for JSP1.2, then declare your web.xml as being DTD 2.3, and leave out that directive.

If you are using JSP2.0, then use the appropriate taglibs - JSTL1.1, and the standard displaytag - not the "el" version.

Hope this helps,
evnafets
 
Hamman
Posts:2
Registered: 8/3/07
EL and JSTL Disabled   
Aug 3, 2007 1:45 AM (reply 8 of 11)  (In reply to #7 )

 
I have a similar problem with EL, but I think it has to do with versions.
I am using JDK version 1.4.0_03 and Tomcat version 5.5.

Its my tag files that contain EL to show the attribute values passed to them. However, I have tried alternate JSTL tags such as suggested above, but it still does not work. I also tried modifying the web.xml file in the /conf directory as suggested above.

As these are tag files, I can't use the page directive anyways. But what confuses me most is that even the JSTL doesn't seem to execute. So I am supposing versions has something to do with it.

I have tried all this on JDK verison 1.5.0_06 and Tomcat 6 where it works perfectly, but I need to do this on 1.4 also. Any help will be appreciated.
 
evnafets
Posts:10,694
Registered: 4/29/03
Re: EL and JSTL Disabled   
Aug 5, 2007 2:51 PM (reply 9 of 11)  (In reply to #8 )

 
Check your web.xml file to make sure it is up to date.
For info on setting up JSTL see this post, reply#6: http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0

I am using JDK version 1.4.0_03 and Tomcat version 5.5.
Tomcat5.5 was written with Java1.5 in mind.
To use Java1.4 with Tomcat5.5 you have to have a compatibility package.
Did you download and install that? (http://tomcat.apache.org/download-55.cgi#5.5.23)
 
Hamman
Posts:2
Registered: 8/3/07
Re: EL and JSTL Disabled   
Aug 8, 2007 12:30 AM (reply 10 of 11)  (In reply to #9 )

 
Thanks, it worked! I read another thread that helped:
http://forum.java.sun.com/thread.jspa?forumID=45&threadID=588217

Here's the documentation of what I did:

1. I updated JDK to 1.5.0_06
2. I updated the header in my web application's "web.xml" file:
<web-app 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" version="2.4">
(Surprisingly, I formerly had version set as 2.5 and it wasn't working, but with 2.4 it works)

3. I restarted Tomcat and reloaded my application
 
evnafets
Posts:10,694
Registered: 4/29/03
Re: EL and JSTL Disabled   
Aug 8, 2007 2:19 PM (reply 11 of 11)  (In reply to #10 )

 
(Surprisingly, I formerly had version set as 2.5 and it wasn't working, but with 2.4 it works)

Thats because Tomcat5.5 only supports ServletSpec 2.4
To run with 2.5 you need Tomcat 6 at least.
 
This topic has 11 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 24
  • Guests : 134

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums