Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
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
Old August 27th, 2003, 01:36 AM
Registered User
Join Date: Aug 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to seeDerekNow
Default CH 9: A simple tag w/ attributes

Hi, can anyone help me w/ this:

1. Created the following custom tag:

<%@ attribute name="normalPrice" fragment="true" %>
 <%@ variable fragment="normalPrice" name-given="name" %>
 <%@ variable fragment="normalPrice" name-given="price" %>

<%@ attribute name="onSale" fragment="true" %>
 <%@ variable fragment="onSale" name-given="name" %>
 <%@ variable fragment="onSale" name-given="origPrice" %>
 <%@ variable fragment="onSale" name-given="salePrice" %>

<table border="1">
   <jsp:invoke fragment="normalPrice">
    <jsp:param name="name" value="Hand-held Color PDA" />
    <jsp:param name="price" value="$298.86" />
   <jsp:invoke fragment="onSale">
    <jsp:param name="name" value="4-Pack 150 Watt Light Bulbs" />
    <jsp:param name="origPrice" value="$2.98" />
    <jsp:param name="salePrice" value="$2.32" />
   <jsp:invoke fragment="normalPrice">
    <jsp:param name="name" value="Digital Cellular Phone" />
    <jsp:param name="price" value="$68.74"/>
   <jsp:invoke fragment="normalPrice">
    <jsp:param name="name" value="baby Grand Piano" />
    <jsp:param name="price" value="$10,800.00" />
   <jsp:invoke fragment="onSale">
    <jsp:param name="name" value="Luxury Car w/ Leather Seats" />
    <jsp:param name="origPrice" value="$23,980.00" />
    <jsp:param name="salePrice" value="$21,070.00" />

2. Created the following JSP:

<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<title>Shopping: A Simple Tag Example</title>

<h1>ABC Store: New Year Sale</h1>

<h2>$$ Weekend Prices...Hurry$$</h2>

 <jsp:attribute name="normalPrice">
 <jsp:attribute name="onSale">
  Item: ${name}<br>
  <strike>Was: ${origPrice}</strike><br>
   <b>Now: ${salePrice}</b>


3. Got the following error when trying to view the page:

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

root cause

java.lang.RuntimeException: org.apache.jasper.JasperException: /WEB-INF/tags/catalog.tag(1,1) Variable directive has invalid attribute: fragment
    org.apache.jasper.compiler.ImplicitTagLibraryInfo. getTagFile(ImplicitTagLibraryInfo.java:173)
    org.apache.jasper.compiler.Parser.parseCustomTag(P arser.java:1340)
    org.apache.jasper.compiler.Parser.parseElements(Pa rser.java:1590)
    org.apache.jasper.compiler.Parser.parse(Parser.jav a:172)
    org.apache.jasper.compiler.ParserController.parse( ParserController.java:254)
    org.apache.jasper.compiler.ParserController.parse( ParserController.java:154)
    org.apache.jasper.compiler.ParserController.parse( ParserController.java:140)
    org.apache.jasper.compiler.Compiler.generateJava(C ompiler.java:250)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:458)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:444)
    org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:603)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:300)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:294)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:856)

Any suggestions?

Old September 28th, 2003, 11:20 PM
Authorized User
Join Date: Aug 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts

Still a problem with several users, *bump* up to recent postings. Current platform is Tomcat 5.0.9 and JSTL 1.0

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Ch 10 Page 370 - Simple User Control surefire BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 February 25th, 2008 01:53 PM
HTML tag from C# or ASP.NET tag from javascript angshujit ASP.NET 2.0 Basics 3 February 16th, 2007 10:07 AM
HTML tag vs Body Tag CFGerry BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 October 7th, 2005 07:13 AM
Trying to output a tag within a tag jaucourt XSLT 3 January 12th, 2005 11:57 AM
Ch 13 p 484 missing <ResourceParams> opening tag JHvdSloot JSP Basics 0 October 2nd, 2003 07:35 AM

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