p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   JSP Basics (http://p2p.wrox.com/forumdisplay.php?f=92)
-   -   Beginning JSP 2.0 + JSTL (http://p2p.wrox.com/showthread.php?t=3006)

AlanZ3 August 20th, 2003 03:17 PM

Beginning JSP 2.0 + JSTL
 
Every example that I try from the Beginning JSP 2.0 book that uses JSTL blows up on me when I try to view the page. A good example is from page 133:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>

<html>
   <head>
      <title>Using a JavaBean</title>
   </head>
   <body>

   <h2>Using a JavaBean</h2>

   <jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />

   I have a <jsp:getProperty name="myCar" property="make" /> <br/>

   My car costs <fmt:formatNumber value="${myCar.price}" type="currency" />

   </body>
</html>

I created the bean OK and it works fine. However, the bold line above causes the following error:

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
    org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:561)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:300)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:293)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:240)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)


root cause

java.lang.IllegalArgumentException: -63
    org.apache.jasper.compiler.SmapStratum$LineInfo.se tOutputLineIncrement(SmapStratum.java:124)
    org.apache.jasper.compiler.SmapStratum.optimizeLin eSection(SmapStratum.java:221)
    org.apache.jasper.compiler.SmapUtil.evaluateNodes( SmapUtil.java:490)
    org.apache.jasper.compiler.SmapUtil.generateSmap(S mapUtil.java:123)
    org.apache.jasper.compiler.Compiler.generateJava(C ompiler.java:301)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:453)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)
    org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:555)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:300)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:293)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:240)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)

I am able to reference the attribute as ${myCar.price} and display it that way but using the formatNumber causes the problem. I get the same problem if I try to use any other taglib e.g. <c:choose>.

I believe that I have the jstl libraries in the correct place, here is my directory structure:

webapps/Reuse/carPage2.jsp
webapps/Reuse/WEB-INF/classes => contains a bunch of directories with the bean inside
webapps/Reuse/WEB-INF/lib => contains all jstl jar files

I am running Tomvat v5.0.7 (installed from .exe file) on Windows 2000. I have jstl standard version 1.0.3.

Any help would be much appreciated.

Alan


pdenhaan August 23rd, 2003 03:52 AM

This looks like an internal Tomcat error, and I don't see anything in your JSP to provoke such a rude error. Remember that Tomcat is still alpha, these things may well happen. Try 5.0.9.

 - Peter


raustin September 28th, 2003 06:58 AM

Try this :

<%@ taglib prefix="fmt_rt" uri="http://java.sun.com/jstl/fmt_rt" %>
<html>
    <head>
        <title>Using a JavaBean</title>
    </head>
    <body>

    <h2>Using a JavaBean</h2>

    <jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />

    I have a <jsp:getProperty name="myCar" property="make" /> <br />
      My car costs <fmt_rt:formatNumber value="${myCar.price}"
                                        type="currency" />

    </body>
</html>

In the book I add _rt to all the taglib prefixes ie

<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
becomes
<%@ taglib prefix="fmt_rt" uri="http://java.sun.com/jstl/fmt_rt" %>

and then when the prefix gets used also make the same change i.e

My car costs <fmt:formatNumber value="${myCar.price}"
becomes
My car costs <fmt_rt:formatNumber value="${myCar.price}"

I've had to to this to every example that uses the fmt,c or sql taglibs.

Hope the above helps..






All times are GMT -4. The time now is 01:38 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.