• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Expression Language does not work

 
Jasmine Zhao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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="http://jakarta.apache.org/taglibs/core" %>
<jsp:useBean id="now" class="java.util.Date" />

<html>
<head>
<title>Test Me</title>
</head>

<body>
<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>
<%out.println(now);%>
</body>

</html>

Result Page:
=====================================
${pageContext.request.method}
Request user Name [null]
${now}
1+2+3 = ${1+2+3}
Fri Oct 01 13:55:42 EDT 2004
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
<%out.println(now);%>


Why on earth are you using out.println() in your JSPs?
 
Jasmine Zhao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Jas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic