• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Expression Language does not work

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic