File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL" Watch "EL" New topic
Author

EL

johaananan brownaaaa
Greenhorn

Joined: Dec 18, 2007
Posts: 22
I trying to test EL on my tomcat, but it just treat to the ELs as text, no processing is done.

Could you please, tell me what sort of configuration should I do?

FYI,

Tomcat 5.5
I tried <%@ page isELIgnored= 'false' %>


Any suggestions guys?

Many thanks
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
What is the version of your deployment descriptor (web.xml)? It needs to be 2.4 or higher else EL will automatically be escaped (as you are seeing) to preserve backward compatibility. This can be found from the first few lines of web.xml (i.e. the DOCTYPE or Schema declarations and the version attribute on <web-app> .


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Kunal Jag
Ranch Hand

Joined: Jun 08, 2008
Posts: 31
The default value for isELIgnored page directive depends on the web.xml artifact; if your web.xml specifies servlets 2.3 (corresponding to JSP 1.2) or earlier, the default is true. However, If your web.xml specifies servlets 2.4 (corresponding to JSP 2.0) or earlier, the default is false. As an illustration, consider the following copde snippet from the DD which declares a deployment plan for Servlets 2.4 and JSP 2.0.



Regards,


Kunal Jaggi<br />Author of <a href="http://www.tatamcgrawhill.com/html/titleDetail.jsp?isbn=9780070249103.html" target="_blank" rel="nofollow">"SCWCD Exam Guide"</a>, SCWCD 5 (exam 310-083 and 310-084), <a href="http://www.tatamcgrawhill.com/html/titleDetail.jsp?isbn=9780070249103.html" target="_blank" rel="nofollow">McGraw-Hill</a><br /><a href="http://javaevangelist.com/" target="_blank" rel="nofollow">http://javaevangelist.com/</a><br /><a href="http://www.oreillynet.com/pub/au/2669" target="_blank" rel="nofollow">http://www.oreillynet.com/pub/au/2669</a>
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
However, If your web.xml specifies servlets 2.4 (corresponding to JSP 2.0) or earlier, the default is false.
I think you mean 2.4 or later there...

This is an odd issue that creeps in quite frequently in these forums. The JSP spec says:
The default mode for JSP pages in a Web Application delivered using a web.xml using the Servlet 2.3 or earlier format is to ignore EL expressions; this provides for backward compatibility.

The default mode for JSP pages in a Web Application delivered using a
web.xml using the Servlet 2.4 format is to evaluate EL expressions; this
automatically provides the default that most applications want.
Note it mentions the default mode. It then goes on to mention that setting the page directive isELIgnored="false" as you have done will override this web.xml default value and cause EL expressions to be evaluated.

However, it seems Tomcat doesn't obey this rule and automatically ignores EL for web.xml version <= 2.3, even if the page directive is set as you have provided. The solution: make sure you are using v2.4 or higher of the deployment descriptor, as given in the previous post.
johaananan brownaaaa
Greenhorn

Joined: Dec 18, 2007
Posts: 22
Thanks guys,
I tried the version as well by the following web.xml for my we application

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4"
>

and the jsp config:

<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>
false
</el-ignored>
</jsp-property-group>
</jsp-config>

the test.jsp is as following:

<%@ page isELIgnored="false" %>


The main domain is: ${applicationScope.domain}


the comcat version is:
5.5.26


Any idea why it doesn't work?

Many thanks,
Pooyan
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
What character encoding is your file saved in? It's possible that if it's not ASCII, ISO-8859-1 or UTF-8 that the $ isn't being picked up by the translator. Try changing the encoding and see if that has an effect (you can also specify the encoding via a page directive).

Also, did you try reloading Tomcat when you made those changes? If not, they might not have taken effect. Try a full restart of the container and see if it's still not working.
[ July 05, 2008: Message edited by: Charles Lyons ]
johaananan brownaaaa
Greenhorn

Joined: Dec 18, 2007
Posts: 22
Hi Charls,

I just edited the page by vi and I think it's character encoding should be ok.

I restarted the tomcat by shutdown.sh and then started it again by startup.sh , but still I am getting the same result a page that displays ${applicationScope.domain}

Do you have any suggestion, I am fed up by this error.

Ta
johaananan brownaaaa
Greenhorn

Joined: Dec 18, 2007
Posts: 22
Thanks Charles,

You were right, I think it was because of encoding, but I changed the page so essentially forced the web container to recompile it.
but still I don't get the expected result, as I defined a parameter in web.xml by
<context-param>
<param-name>myDog</param-name>
<param-value>Doberman Ponscher</param-value>
</context-param>

when I use ${applicationScope.myDog}, it doesn't dsiplay it, just come up empty.

Any idea why?

Ta
Pooyan
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Eeeek - you've fallen into the classic trap. "applicationScope" is a Map containing all context-scoped attributes and not context parameters! You need to use ${initParam.myDog}.

A similar common mistake is presented by the servlet/JSP init parameters; see: http://faq.javaranch.com/java/InitParamsThruExpressionLanguage.

Does that sort it for you?
[ July 05, 2008: Message edited by: Charles Lyons ]
johaananan brownaaaa
Greenhorn

Joined: Dec 18, 2007
Posts: 22
Yes!! it's working! finally got a result by EL! thanks so much Charles!
Jan Sterk
Ranch Hand

Joined: Jun 06, 2008
Posts: 139
Originally posted by Pouyan Farhani:
...
<param-value>Doberman Ponscher</param-value>
</context-param>
...


Isn't it spelled like Doberman Pinscher?


SCJP 1.4 (81%)<br />SCWCD 5 (95%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL
 
Similar Threads
Expression Language + Tomcat
Expression Language Doubt
JSTL and EL
How to run simple JSTL page?
how to write an El expression