It's not a secret anymore!*
The moose likes JSP and the fly likes EL is 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 is not working" Watch "EL is not working" New topic
Author

EL is not working

Prasad Yarehalli
Greenhorn

Joined: Dec 08, 2005
Posts: 12
I am new to Java and JSP. I passed SCJP 1.4 recently and I am working on SCWCD preparation. I am in the process of learning EL in JSP. But my EL doesn't seem to work at all. When my EL's are rendered , I get the same as I typed in/ Is there any setting that I have to do make it work?
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
No, ELs are by default enabled.

But you can check into web.xml and JSP directives if you have change any setting.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

Originally posted by rathi ji:
No, ELs are by default enabled.


No, not always.

What servlet/JSP container are you using? If it's Tomcat 5, you need to make sure that your web app is declared as a servlets 2.4 web app in the deployment descriptor. See the JSP FAQ for more info.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Bear Bibeault:


No, not always.

What servlet/JSP container are you using? If it's Tomcat 5, you need to make sure that your web app is declared as a servlets 2.4 web app in the deployment descriptor. See the JSP FAQ for more info.


But it is written in HFS&J. Page 320.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by rathi ji:
But it is written in HFS&J. Page 320.


EL is only supported in the most recent versions of the JSP spec.
To insure backward compatibility, containers will refer to the DTD in the deployment descriptor to see which version the app is using.

Also, if you are going to refer to text in a book, please do not just post the page number.
Post the relevant text. Don't assume that everyone reading these posts owns the same books that you do.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
shiva rao
Ranch Hand

Joined: May 26, 2005
Posts: 31
I am also facing same problem. I checked FAQ

Here is my deployment discriptor main tag entry, where I specified the version as 2.4

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

I checked JSP FAQ at http://java.sun.com/products/jsp/faq.html there also I haven't foundmuch.

Here is my full jsp source.
-------------------------
<html>
<body>
<%@ page isELIgnored="false"%>
<%! String texts="Welcome to Expression language"; %>
Welcome to the jsp programming.
<br/>
<strong>If you see this page, it means jsp are also funtioning properly.</strong>
<form action="result.jsp">
<input type="text" name="username"/>
<input type="password" name="userpassword"/>
<input type="submit" value="Save"/>
Text = ${texts}
</form>
</body>
</html>
--------------------------------------------

For somereason it is still now workging. Please let me know if I am missing something.

I am using Tomcat 5.5, XP Pro envi
Thanks!

Shiva rao
[ December 09, 2005: Message edited by: shiva rao ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

In your example:

<%! String texts="Welcome to Expression language"; %>

...

Text = ${texts}


you define texts as a scriptlet variable. The EL references scoped variables.

The JSTL and EL have no provisions for referencing scripting elements.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Ben Souther:

Also, if you are going to refer to text in a book, please do not just post the page number.
Post the relevant text. Don't assume that everyone reading these posts owns the same books that you do.


The text from the book is: El is enabled by default!

I think it was not very tough to guess what is written in the book from my post. I try to post text from the book when it is required.

Thanks.

[ December 11, 2005: Message edited by: rathi ji ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Rathi,
This conversation is straying from the original poster's question.
Please see my PM on the book quoting issue.
If you would like to know why it's impossible for EL to be turned on by default in container versions that were released before the existence of EL, start a new thread please.
[ December 10, 2005: Message edited by: Ben Souther ]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Rathi, Ben is correct. The book is probably referring to JSP 2.0, in which case EL is enabled by default. If using jSP 1.2 or earlier EL is not enabled by default.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EL is not working