File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Expression Language does not work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Expression Language does not work" Watch "Expression Language does not work" New topic

Expression Language does not work

Jasmine Zhao

Joined: Oct 01, 2004
Posts: 8

I just tried the following code and tomcat did not understand the EL part.

Could anybody tell me what I did wrong and missed out? I have tomcat 5 and Java 1.4 installed.

Jsp code
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="" %>
<jsp:useBean id="now" class="java.util.Date" />

<title>Test Me</title>

<c ut value="${pageContext.request.method}" /> <br>
<% out.println ("Request user Name [" + request.getParameter("userName") +"]"); %> <br>
<c ut value="${now}" /> <br>
1+2+3 = ${1+2+3} <br>


Result Page:
Request user Name [null]
1+2+3 = ${1+2+3}
Fri Oct 01 13:55:42 EDT 2004
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Do you have your web app declared as a Servlet 2.3 or 2.4 web app in your web.xml file? If you declare it as Servlet 2.4 app, the EL will be automatically "turned on" on your pages.

As an aside:

Why on earth are you using out.println() in your JSPs?

[Asking smart questions] [About Bear] [Books by Bear]
Jasmine Zhao

Joined: Oct 01, 2004
Posts: 8
Thanks a lot. I did what you told me and it works now.

I used <%out.println(now);%> just to verify if the old things were still working. You know if things don't work, you suspect everything.

Anyway, thanks again.

I agree. Here's the link:
subject: Expression Language does not work
It's not a secret anymore!