Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL

 
johaananan brownaaaa
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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> .
 
Kunal Jag
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 836
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes!! it's working! finally got a result by EL! thanks so much Charles!
 
Jan Sterk
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pouyan Farhani:
...
<param-value>Doberman Ponscher</param-value>
</context-param>
...


Isn't it spelled like Doberman Pinscher?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic