You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by p f <pl...@hotmail.com> on 2001/06/22 18:53:58 UTC

TagLibrary Specification Question

Sorry I neglected to put a subject line in my
original email.


>From: "p f" <pl...@hotmail.com>
>To: taglibs-dev@jakarta.apache.org
>CC: plf112@hotmail.com
>Date: Fri, 22 Jun 2001 16:52:29 -0000
>
>I would like to find out if using overloaded set/get methods within a Tag
>Handler
>is within the JSP 1.1 / JavaBeans 1.01 specifications or not.
>
>
>Problem:
>     When using a tag whose  handler contains overloaded set methods,
>     the JSP 1.1 compiler fails with this error:
>          Server caught unhandled exception from servlet:
>          Unable to find setter method for attribute: value
>
>     The accompanying stack trace is included at the bottom of this file.
>     Platform is NT, App Server is WebSphere 3.5 Fixpack 2 with JSP 1.1
>processor.
>
>Question:
>       Is overloading get/set methods in accordance with specifications?
>       I cannot find any spec (JSP 1.1 spec, Java Beans 1.01 spec)
>       that says you can or cannot have overloaded set methods.   I do have 
>a
>book that mentions
>       overloading set/get methods:
>
>       "...You can also overload your getter and setter methods to accept
>        the appropriate object type, although custom tags or JSP scripting
>elements will be
>        required to access the overloaded methods since
>        the <jsp:setProperty> and <jsp:getProperty> tags work exclusively
>with Strings..."
>
>      This excerpt is from   'Web Development with Java Server Pages, by
>Fields/Kolb, published by Manning
>      Publications and is availiable on the web at
>http://www.manning.com/Fields/Excerpts.html.
>
>      I want to find out if overloading the set method is within the spec 
>or
>not.
>
>Supporting information included below:
>
>     1.  repro.jsp       -  JSP that uses tags to demonstrate the problem
>     2.  setvar.tld      -  tag library descriptor
>     3.  setvar.java     -  tag handler code
>     4.  stack trace     -  text file containing stack trace that 
>accompanies
>the exception error
>                            when repro.jsp is invoked.
>
>
>----------------------------------------------------------------------------
>------------------------------
>1. repro.jsp      invoke via browser:
>http://<host>/<path>/repro.jsp?param=someValue
>
><%@ taglib prefix="sv" uri="/setvar.tld" %>
>
>
>
>----------------------------------------------------------------------------
>------------------------------
>2. setvar.tld
>
><?xml version="1.0" encoding="ISO-8859-1" ?>
><!DOCTYPE taglib
>         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
>         "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
><!--  setvar.tld   -->
><taglib>
>	<tlibversion>1.0</tlibversion>
>	<jspversion>1.1</jspversion>
>	<shortname>sv</shortname>
>	<info>tld for setvar test case</info>
>         <tag>
>              <name>setvar</name>
>              <tagclass>com.openmarket.tstcase.setvar</tagclass>
>              <bodycontent>empty</bodycontent>
>              <info> simple tag to repro jsp compile error </info>
>              <attribute>
>                  <name>value</name>
>                  <required>true</required>
>                  <rtexprvalue>true</rtexprvalue>
>              </attribute>
>         </tag>
></taglib>
>
>----------------------------------------------------------------------------
>------------------------------
>3. setvar.java
>
>package com.tstcase;
>
>import java.io.*;
>import javax.servlet.jsp.*;
>import javax.servlet.jsp.tagext.*;
>
>public class setvar extends TagSupport {
>
>private String name;
>private String value;
>
>   public int doStartTag() {
>
>    try {
>      JspWriter out = pageContext.getOut();
>      out.print("<BR>setvar:  value = " + value + "</BR>");
>    }
>      catch(IOException err)
>      {System.out.println("Error in setvar " + err);}
>
>    return(EVAL_BODY_INCLUDE);
>
>   }
>
>   public void setValue(String value) {
>     this.value = value;}
>
>   public String getValue() {
>     return value;}
>
>// to prevent the error when repro.jsp is invoked, comment out the next 2
>lines
>   public void setValue(int n) {
>     value = Integer.toString(n);}
>
>
>}
>----------------------------------------------------------------------------
>------------------------------
>
>4. stack trace
>
>Stack Trace:
>
>[01.06.22 11:03:23:814 EDT] b354cfab WebGroup      X [Servlet Error]-[{0}]:
>{1}: {2}
>                                  "WCS JSP Compiler"
>                                  "Server caught unhandled exception from
>servlet [WCS JSP Compiler]:
>                                  Unable to find setter method for 
>attribute:
>value"
>
>com.ibm.servlet.engine.webapp.UncaughtServletException: Server caught
>unhandled exception from servlet [WCS JSP Compiler]: Unable to find setter
>method for attribute: value
>at javax.servlet.ServletException.<init>(ServletException.java:132)
>at
>com.ibm.websphere.servlet.error.ServletErrorReport.<init>(ServletErrorReport
>.java:43)
>at
>com.ibm.servlet.engine.webapp.WebAppErrorReport.<init>(WebAppErrorReport.jav
>a:32)
>at
>com.ibm.servlet.engine.webapp.UncaughtServletException.<init>(UncaughtServle
>tException.java:11)
>at
>com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(W
>ebAppRequestDispatcher.java:355)
>at
>com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequest
>Dispatcher.java:175)
>at
>com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestD
>ispatcher.java:93)
>at
>com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.
>java:77)
>at
>com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedIn
>vocation.java:67)
>at
>com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(Cacheabl
>eInvocationContext.java:106)
>at
>com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequ
>estProcessor.java:160)
>at
>com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener
>.java:300)
>at
>com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQ
>EventListenerImp.java:230)
>at
>com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventL
>istenerImp.java:104)
>at
>com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQE
>ventSource.java:212)
>at
>com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRu
>nnable.notifyService(SQWrapperEventSource.java:347)
>at
>com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRu
>nnable.run(SQWrapperEventSource.java:216)
>at
>com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run
>(OutOfProcThread.java:248)
>at java.lang.Thread.run(Thread.java:481)
>
>
>
>
>

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Re: TagLibrary Specification Question

Posted by Michael Amster <ma...@webeasy.com>.
P F:

I ran into the same thing and it turned out that the name of the field value may
be problematic.  Try a different name like val or something and modify the
get/set methods appropriately.

The server should be using java.lang.reflect to match the set method with what
you are passing.  Since the base class TagSupport has a setValue method that does
something different from what you want, it may just be handling the reflection
wrong.

-MA

p f wrote:

> Sorry I neglected to put a subject line in my
> original email.
>
> >From: "p f" <pl...@hotmail.com>
> >To: taglibs-dev@jakarta.apache.org
> >CC: plf112@hotmail.com
> >Date: Fri, 22 Jun 2001 16:52:29 -0000
> >
> >I would like to find out if using overloaded set/get methods within a Tag
> >Handler
> >is within the JSP 1.1 / JavaBeans 1.01 specifications or not.
> >
> >
> >Problem:
> >     When using a tag whose  handler contains overloaded set methods,
> >     the JSP 1.1 compiler fails with this error:
> >          Server caught unhandled exception from servlet:
> >          Unable to find setter method for attribute: value
> >
> >     The accompanying stack trace is included at the bottom of this file.
> >     Platform is NT, App Server is WebSphere 3.5 Fixpack 2 with JSP 1.1
> >processor.
> >
> >Question:
> >       Is overloading get/set methods in accordance with specifications?
> >       I cannot find any spec (JSP 1.1 spec, Java Beans 1.01 spec)
> >       that says you can or cannot have overloaded set methods.   I do have
> >a
> >book that mentions
> >       overloading set/get methods:
> >
> >       "...You can also overload your getter and setter methods to accept
> >        the appropriate object type, although custom tags or JSP scripting
> >elements will be
> >        required to access the overloaded methods since
> >        the <jsp:setProperty> and <jsp:getProperty> tags work exclusively
> >with Strings..."
> >
> >      This excerpt is from   'Web Development with Java Server Pages, by
> >Fields/Kolb, published by Manning
> >      Publications and is availiable on the web at
> >http://www.manning.com/Fields/Excerpts.html.
> >
> >      I want to find out if overloading the set method is within the spec
> >or
> >not.
> >
> >Supporting information included below:
> >
> >     1.  repro.jsp       -  JSP that uses tags to demonstrate the problem
> >     2.  setvar.tld      -  tag library descriptor
> >     3.  setvar.java     -  tag handler code
> >     4.  stack trace     -  text file containing stack trace that
> >accompanies
> >the exception error
> >                            when repro.jsp is invoked.
> >
> >
> >----------------------------------------------------------------------------
> >------------------------------
> >1. repro.jsp      invoke via browser:
> >http://<host>/<path>/repro.jsp?param=someValue
> >
> ><%@ taglib prefix="sv" uri="/setvar.tld" %>
> >
> >
> >
> >----------------------------------------------------------------------------
> >------------------------------
> >2. setvar.tld
> >
> ><?xml version="1.0" encoding="ISO-8859-1" ?>
> ><!DOCTYPE taglib
> >         PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
> >         "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
> ><!--  setvar.tld   -->
> ><taglib>
> >       <tlibversion>1.0</tlibversion>
> >       <jspversion>1.1</jspversion>
> >       <shortname>sv</shortname>
> >       <info>tld for setvar test case</info>
> >         <tag>
> >              <name>setvar</name>
> >              <tagclass>com.openmarket.tstcase.setvar</tagclass>
> >              <bodycontent>empty</bodycontent>
> >              <info> simple tag to repro jsp compile error </info>
> >              <attribute>
> >                  <name>value</name>
> >                  <required>true</required>
> >                  <rtexprvalue>true</rtexprvalue>
> >              </attribute>
> >         </tag>
> ></taglib>
> >
> >----------------------------------------------------------------------------
> >------------------------------
> >3. setvar.java
> >
> >package com.tstcase;
> >
> >import java.io.*;
> >import javax.servlet.jsp.*;
> >import javax.servlet.jsp.tagext.*;
> >
> >public class setvar extends TagSupport {
> >
> >private String name;
> >private String value;
> >
> >   public int doStartTag() {
> >
> >    try {
> >      JspWriter out = pageContext.getOut();
> >      out.print("<BR>setvar:  value = " + value + "</BR>");
> >    }
> >      catch(IOException err)
> >      {System.out.println("Error in setvar " + err);}
> >
> >    return(EVAL_BODY_INCLUDE);
> >
> >   }
> >
> >   public void setValue(String value) {
> >     this.value = value;}
> >
> >   public String getValue() {
> >     return value;}
> >
> >// to prevent the error when repro.jsp is invoked, comment out the next 2
> >lines
> >   public void setValue(int n) {
> >     value = Integer.toString(n);}
> >
> >
> >}
> >----------------------------------------------------------------------------
> >------------------------------
> >
> >4. stack trace
> >
> >Stack Trace:
> >
> >[01.06.22 11:03:23:814 EDT] b354cfab WebGroup      X [Servlet Error]-[{0}]:
> >{1}: {2}
> >                                  "WCS JSP Compiler"
> >                                  "Server caught unhandled exception from
> >servlet [WCS JSP Compiler]:
> >                                  Unable to find setter method for
> >attribute:
> >value"
> >
> >com.ibm.servlet.engine.webapp.UncaughtServletException: Server caught
> >unhandled exception from servlet [WCS JSP Compiler]: Unable to find setter
> >method for attribute: value
> >at javax.servlet.ServletException.<init>(ServletException.java:132)
> >at
> >com.ibm.websphere.servlet.error.ServletErrorReport.<init>(ServletErrorReport
> >.java:43)
> >at
> >com.ibm.servlet.engine.webapp.WebAppErrorReport.<init>(WebAppErrorReport.jav
> >a:32)
> >at
> >com.ibm.servlet.engine.webapp.UncaughtServletException.<init>(UncaughtServle
> >tException.java:11)
> >at
> >com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(W
> >ebAppRequestDispatcher.java:355)
> >at
> >com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequest
> >Dispatcher.java:175)
> >at
> >com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestD
> >ispatcher.java:93)
> >at
> >com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.
> >java:77)
> >at
> >com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedIn
> >vocation.java:67)
> >at
> >com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(Cacheabl
> >eInvocationContext.java:106)
> >at
> >com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequ
> >estProcessor.java:160)
> >at
> >com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener
> >.java:300)
> >at
> >com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQ
> >EventListenerImp.java:230)
> >at
> >com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventL
> >istenerImp.java:104)
> >at
> >com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQE
> >ventSource.java:212)
> >at
> >com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRu
> >nnable.notifyService(SQWrapperEventSource.java:347)
> >at
> >com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRu
> >nnable.run(SQWrapperEventSource.java:216)
> >at
> >com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run
> >(OutOfProcThread.java:248)
> >at java.lang.Thread.run(Thread.java:481)
> >
> >
> >
> >
> >
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com

--
~-~-~-~-~-~-~-~-~-~-~-~-~-~-WEBEASY-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
Michael Amster              mamster@webeasy.com
1416 2nd Street             Tel: 310.576.0770
Santa Monica, CA 90401      Fax: 310.576.2011