Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Tomcat 5 & Custom Tag Variable Problems

Tomcat 5 & Custom Tag Variable Problems

2004-01-06       - By Richard Wareing

 Back
Well, I finally got around to playing with Tomcat 5, and everything
seems to work well except for my custom tags (which is to say my whole
web app broke :) ).  

My problem is when tomcat tries to process my custom tags I get an error
as follows:

org.apache.jasper.JasperException Source code of org.apache.jasper.JasperException: /index.jsp(13,0) Unknown attribute
type (String) for attribute bar.
 
org.apache.jasper.compiler.DefaultErrorHandler Source code of org.apache.jasper.compiler.DefaultErrorHandler(DefaultErrorHand
ler.java:83)
 
org.apache.jasper.compiler.ErrorDispatcher Source code of org.apache.jasper.compiler.ErrorDispatcher(ErrorDispatcher.java
:402)
*SNIP*

Anyone have an idea as to what might be wrong?  Keep in mind, everything
worked fine with Tomcat 4.x.  The only thing I can think of is that
perhaps this has something to do with TEI classes (which I have never
bothered with before)?  In the mean time I think I'll start slogging
through the JSP 2.0 spec, but if anyone can prevent me from thinking for
myself that would be appreciated :).

Thanks in Advance,

Richard Wareing
Reimer Technology Group

P.S. Here is a simple test case which demonstrates the problem (I have
it in a nice zip file with the directory structure if anyone wants it):

FooTag simply prints out the contents of a variable "bar" when it is
passed along, otherwise prints out a default message of "Nothing set!":

/index.jsp:
================START===============

<%@(protected) contentType="text/html"%>

<%@ taglib uri="/taglibs/testcase.tld" prefix="forminputs" %>


<html>
<head><title>Tomcat 5 Testcase</title></head>
<body>

<%-- <jsp:useBean id="beanInstanceName" scope="session"
class="package.class" /> --%>
<%-- <jsp:getProperty name="beanInstanceName"  property="propertyName"
/> --%>

<forminputs:fooTag bar='<%= "Hope this works!" %>' >
<h1> <%= outputString %> </h1>
</forminputs:fooTag>


</body>
</html>

================END===============


/taglibs/testcase.tld:
================START===============
<?xml version="1.0" encoding="UTF-8 (See http://UTF-8.ora-code.com)" ?>

<!DOCTYPE taglib
       PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
       "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">



<taglib>
   <tlib-version>1.0</tlib-version>
   <jsp-version>1.2</jsp-version>
   <short-name>testcase</short-name>
   <uri>/testcase</uri>
   <display-name>testcase</display-name>
   <description>A blank tag library template.
   </description>
   <tag>
       <name>fooTag</name>
       <tag-class>tomcat5.testcase.FooTag</tag-class>
       <body-content>JSP</body-content>
       <small-icon></small-icon>
       <large-icon></large-icon>
       <description></description>
       <!-- Forte4J_TLDX:  This comment contains code generation
information. Do not delete.
       <tldx>
           <packagename>tomcat5.testcase</packagename>
           <extendsSupportClass>TRUE</extendsSupportClass>
           <supportClass>BodyTagSupport</supportClass>
           <implementsTryCatchFinally>FALSE</implementsTryCatchFinally>
           <findparent>FALSE</findparent>
           <parenttype></parenttype>
           <parentvariable></parentvariable>
       </tldx>
       -->
       

       <variable>
           <name-given>outputString</name-given>
           <variable-class>String</variable-class>
           <declare>true</declare>
           <scope>NESTED</scope>
<!-- Forte4J_TLDX:  This comment contains code generation information.
Do not delete.
           <tldx>
               <name>outputString</name>            </tldx>
           -->
       </variable>

       <attribute>
           <name>bar</name>
           <required>false</required>
           <rtexprvalue>true</rtexprvalue>
           <type>String</type>
           <!-- Forte4J_TLDX:  This comment contains code generation
information. Do not delete.
           <tldx>
               <javaVariable></javaVariable>
               
               <IsReferenceID>FALSE</IsReferenceID>
               <ReferencesTag>FALSE</ReferencesTag>
               <ReferenceScope>Session</ReferenceScope>
               <ReferencesTagType></ReferencesTagType>
               <ReferencesTagVariable></ReferencesTagVariable>
               
               

<ReferencesTagReferentFirst>TRUE</ReferencesTagReferentFirst>
           </tldx>
           -->
       </attribute>
       <example></example>
   </tag>
   
       
   <!-- Validators are new in JSP1.2. You may have zero or one
validator
        in a tag library. They look like this:
     <validator>

<validator-class>org.your.web.app.ValidateTaglibUsage</validator-class>
         <init-param>
            <param-name>aparameter</param-name>
            <param-value>value</param-value>
            <description>Describe this parameter</description>
   </init-param>
     </validator>
  -->

  <!-- listeners are new in JSP1.2. You may have as many listeners as
you like
       in a tag library. They look like this:
    <listener>

<listener-class>org.your.web.app.TaglibListener1</listener-class>
    </listener>
  -->
</taglib>

================END===============


tomcat5.testcase.FooTag Source
================START===============

package tomcat5.testcase;

import java.io.*;
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.util.*;

/**
*  Generated tag class.
*/
public class FooTag extends BodyTagSupport {

   /** property declaration for tag attribute: selectedValue
    *
    */    
   private String bar;
   
   public FooTag() {
       super();
   }
   
   
   public void otherDoStartTagOperations()  {
   }
   
   public boolean theBodyShouldBeEvaluated()  {
       boolean retVal = false;
       if ( bar != null ) {
           setVars();
           retVal = true;
       }
       return true;
   }
   
   
   public void otherDoEndTagOperations()  {
   }
   
   public boolean shouldEvaluateRestOfPageAfterEndTag()  {
       return true;
   }
   
   
   public int doStartTag() throws JspException, JspException {
       
       otherDoStartTagOperations();
       
       if (theBodyShouldBeEvaluated()) {
           return EVAL_BODY_BUFFERED;
       } else {
           return SKIP_BODY;
       }
   }
   
   public int doEndTag() throws JspException, JspException {
       otherDoEndTagOperations();
       
       if (shouldEvaluateRestOfPageAfterEndTag()) {
           return EVAL_PAGE;
       } else {
           return SKIP_PAGE;
       }
   }
   
   public void writeTagBodyContent(JspWriter out, BodyContent
bodyContent) throws IOException {
       bodyContent.writeOut(out);
       bodyContent.clearBody();
   }
   
   public void handleBodyContentException(Exception ex) throws
JspException {
       // Since the doAfterBody method is guarded, place exception
handing code here.
       throw new JspException("error in FooTag: " + ex);
   }
   
   public int doAfterBody() throws JspException {
       try {
           BodyContent bodyContent = getBodyContent();
           JspWriter out = bodyContent.getEnclosingWriter();
           
           writeTagBodyContent(out, bodyContent);
       } catch (Exception ex) {
           handleBodyContentException(ex);
       }
       
       if (theBodyShouldBeEvaluatedAgain()) {
           return EVAL_BODY_AGAIN;
       } else {
           return SKIP_BODY;
       }
   }
   
   public boolean theBodyShouldBeEvaluatedAgain() {
       return false;
   }
   
   public java.lang.String Source code of java.lang.String setValueOfVariable_outputString() {
       String s = "Nothing set!";
       if ( ( bar != null) && ( bar.length() > 0 ) )
           s = bar;
       return s;
   }
   

   public void setVars() {
       //
       // Set the name and value of the scripting variable
"optionValue"
       //
       {
           //
           // The name of this variable is fixed.
           //
           String nameVar = "outputString";
           
           //
           // Set the value of the variable "timeOffset"  by modifying
the
           // method: setValueOfVariable_timeOffset().
           //
           if (nameVar != null) {
               java.lang.String Source code of java.lang.String valueObject =
setValueOfVariable_outputString();
               if (valueObject != null) {
                   pageContext.setAttribute(nameVar, valueObject);
               }
           }
       }

   }
   
   
   public String getBar() {
       return bar;
   }
   
   public void setBar(String bar) {
       this.bar = bar;
   }

}
================END===============


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.