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
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
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
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.
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.
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
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.
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)