George Hester wrote:
OK what I have done is transfer some of the standard taglib 1.0
> examples to my webapp.  I know these taglibs are working because
> I used the import and pulled up my ftp site.  So I don't think
> there is anything wrong with my installation.  I think the
> counters1.jsp is bum.  I got that right out of the book by O'Reilly
> called Tomcat.  And I don't think it works.  That's par for the course
> with these books on programming.  At least that has been my
> experience.

Here's their code:


<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
<html>
<head>
<title>Counter Page</title>
</head>
<body bgcolor="white">
<%-- Increment Counters --%>
<c:set var="sessionCounter" scope="session" value="${sessionCounter + 1}"/>
<c:set var="applCounter" scope="application" value="${applCounter + 1}"/>
<h1>Counter page</h1><p>
This page has been visited <b>${sessionCounter}</b> times within the current 
session<br/>
and <b>${applCounter}</b> times by all users since the application was started.</p>
</body>
</html>

And here's the result:

Counter page

This page has been visited ${sessionCounter} times within the current session
and ${applCounter} times by all users since the application was started.


$40 for this and on pg 30. I'll just have to find a book with working code.
> I been through Wrox; Sun and now it look like O'Reilly is no
> different in publishing code that looks good on paper but fails in practice.
> Thanks for your attention on this. The install is fine.


This page uses JSP 2.0 syntax (EL expressions directly in template
text), and from your previous posts it seems like your using a JSP
1.2 container (Tomcat 4.1.x). You must use a JSP 2.0 container, such
as Tomcat 5.x instead. In this example it doesn't really matter, but
you should also use JSTL 1.1 instead of 1.0 with a JSP 2.0 container.

The EL is disabled by default if you use a JSP 1.2/Servlet 2.3 web.xml
file, so you must also use a JSP 2.0/Servlet 2.4 web.xml file, i.e,
one that starts with:

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


Unless there's a copy of this example in another O'Reilly book, this looks like an example from my book named "JavaServer Pages, 3rd Edition", not "Tomcat" as you say above. It's clearly marked both on the cover and in the text to describe JSP 2.0, and it shows you how to install Tomcat 5, not 4.x, in Chapter 4. And the sample application comes with the correct web.xml version. So please, keep the versions straight and I can guarantee you that the examples work as they should.

Hans
--
Hans Bergsten                                <[EMAIL PROTECTED]>
Gefion Software                       <http://www.gefionsoftware.com/>
Author of O'Reilly's "JavaServer Pages", covering JSP 2.0 and JSTL 1.1
Details at                                    <http://TheJSPBook.com/>


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to