File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes EL not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "EL not working" Watch "EL not working" New topic
Author

EL not working

preetiarvind sharma
Greenhorn

Joined: Nov 17, 2005
Posts: 22
Hi there,

I cant get EL running. I am using tomcat 5 and the example I am using is from the Sun' website. Is there any other setting I have to make to have them running.


Here is the example
<HTML>
<HEAD>
<TITLE>Expression Language Examples</TITLE>
</HEAD>

<BODY>

<H3>JSP Expression Language Examples</H3>
<P>
The following table illustrates some EL expressions and implicit objects:

<TABLE BORDER="1">
<THEAD>
<TD><B>Expression</B></TD>
<TD><B>Value</B></TD>
</THEAD>
<TR>
<TD>\${2 + 5}</TD>
<TD>${2 + 5}</TD>
</TD>
<TR>
<TD>\${4/5}</TD>
<TD>${4/5}</TD>
</TR>
<TR>
<TD>\${5 div 6}</TD>
<TD>${5 div 6}</TD>
</TR>
<TR>
<TD>\${5 mod 7}</TD>
<TD>${5 mod 7}</TD>
</TR>
<TR>
<TD>\${2 < 3}</TD>
<TD>${2 < 3}</TD>
</TR>
<TR>
<TD>\${2 gt 3}</TD>
<TD>${2 gt 3}</TD>
</TR>
<TR>
<TD>\${3.1 le 3.2}</TD>
<TD>${3.1 le 3.2}</TD>
</TR>
<TR>
<TD>\${(5 > 3) ? 5 : 3}</TD>
<TD>${(5 > 3) ? 5 : 3}</TD>
</TR>
<TR>
<TD>\${header["host"]}</TD>
<TD>${header["host"]}</TD>
</TR>
<TR>
<TD>\${header["user-agent"]}</TD>
<TD>${header["user-agent"]}</TD>
</TR>

</TABLE>

</BODY>
</HTML>


Thanks
Preeti
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

See the JSP FAQ entry on this. Be sure that you are using compatible versions of the JSTL, and that your web.xml is declared correctly.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shiva rao
Ranch Hand

Joined: May 26, 2005
Posts: 31
You can activate the EL by two ways.

1) JSP directive

<%@ page isELIgnored="false"%>

2) deployment descriptor

<el-ignored>false</el-ignored>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Originally posted by shiva rao:
You can activate the EL by two ways.


Or by the 3rd and preferable way: just set up the application properly and you don't need to do any of that.
preetiarvind sharma
Greenhorn

Joined: Nov 17, 2005
Posts: 22
I have the correct version of jstl (that is 1.1) and my web.xml is also declared correctly as mentioned in the JSP FAQs. Still cant get that working. Is there anything else I may be missing??

regards
preeti
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Actually, the JSTL is moot at this point since you are not using the EL within JSTL tags (but 1.1 is the correct version).

How is your web.xml declared? Correctly declaring it using the Servlets 2.4 XML Schema should be all that you need in order to enable the EL in all pages.
preetiarvind sharma
Greenhorn

Joined: Nov 17, 2005
Posts: 22
I got that Bear.
here is my web.xml. CAn you have a look at that please?

<?xml version="1.0" encoding="ISO-8859-1"?>

<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">


<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>

<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>servlets.TestServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/test/Testme</url-pattern>
</servlet-mapping>
<jsp-config>
<jsp-property-group>
<el-ignored>
false
</el-ignored>
</jsp-property-group>
</jsp-config>

</web-app>


I have just added the code in the bold to make sure EL is enabled, though I think it is enabled by default in JSP2.0.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

Originally posted by preetiarvind sharma:

I have just added the code in the bold to make sure EL is enabled, though I think it is enabled by default in JSP2.0.


Exactly, so I would remove that element since it doesn't seem to be making any difference anyways.

The declaration looks ok. And you say the EL is not being evaluated? As in the ${whatever} expresssions are still in the response sent to the browser?
preetiarvind sharma
Greenhorn

Joined: Nov 17, 2005
Posts: 22
Thats right. EL isnt being evaluated and any EL is being written just as a text in the browser somwhat like this.

Cant think of any reason for this?




preeti
preetiarvind sharma
Greenhorn

Joined: Nov 17, 2005
Posts: 22
Hey Bear,

That worked. Thanks for all the help


Preeti
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61187
    
  66

What made is start working for you? (In case anyone else has the same issue).
preetiarvind sharma
Greenhorn

Joined: Nov 17, 2005
Posts: 22
Hi Bear,
I think that was the caching issues, Making a small change in the text of the page and reloading it again worked for me.

Thanks again for all the help.

Cheers
preeti
Jacob Fenwick
Ranch Hand

Joined: Apr 28, 2006
Posts: 55
I had this exact problem and out of all the internet this was the only page that had the answer.
This has something to do with how the jsp isn't being recompiled into a java class in tomcat/work, correct? Any insight into why this happens?
 
 
subject: EL not working