Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
| Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 20th, 2003, 03:17 PM
Registered User
 
Join Date: Aug 2003
Location: , SC, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

  #2 (permalink)  
Old August 23rd, 2003, 03:52 AM
Authorized User
 
Join Date: Aug 2003
Location: Coventry, , United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

  #3 (permalink)  
Old September 28th, 2003, 06:58 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning JSP question about JSTL EricD JSP Basics 2 July 6th, 2006 03:32 AM
Wroc Beginning JSP 2.0 wireblock All Other Wrox Books 11 November 7th, 2004 08:43 PM
Beginning JSP 2.0 chapter 2 Charles Howard JSP Basics 2 May 17th, 2004 12:32 AM
Beginning JSP colin2455 Forum and Wrox.com Feedback 2 March 30th, 2004 03:52 PM
"Advanced" example in beginning JSP Darren JSP Basics 1 July 23rd, 2003 10:55 AM





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