tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Larson <lars...@ncep.noaa.gov>
Subject Tomcat's non-polymorphic request handler.
Date Thu, 20 Sep 2001 15:52:54 GMT

I'm having some difficulty with the polymorphic behavior of Tomcat's
  request handler.
  Consider the following:

  package RMS;
  import java.lang.Integer;

  public class TestPolyMorph {
      int i;
      String s;
      public void setNumberVar(String i) {
          this.i = Integer.parseInt(i);
      }
      public void setNumberVar(int i) {
          this.i = i;
      }
      public int getNumber() {
          return(i);
      }
      public void setStringVar(String s) {
          this.s = s;
      }
      public String getStringVar(String s) {
          return(s);
      }
      public TestPolyMorph() {
      }
  }

  ... and the .JSP file:

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
  <html>
  <head>
  <!--  <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="Mon, 01 Jan 1990 00:00:01 GMT">
  -->
    <meta http-equiv="Content-Type"
  content="text/html;CHARSET=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
  </head>
  <%@ page language="java" import="RMS.*" %>
  <jsp:useBean    id="ui" class="RMS.TestPolyMorph" scope="session"/>
  <jsp:setProperty name="ui" property="*"/>
  <body>
  Testing... Testing... Testing.
  </body>
  </html>

  Now... the passing a non-integer value for the property: numberVar
will
  yield a stack trace:
  http://SERVER:PORT/CONTEXT/jsp/TestPolyMorph.jsp?numberVar=foobar

  org.apache.jasper.JasperException: 3.2
   at

org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:204)

   at

org.apache.jasper.runtime.JspRuntimeLibrary.introspect(JspRuntimeLibrary.java:152)

   at
  jsp._0002fjsp_0002fTestPolyMorph_00

02ejspTestPolyMorph_jsp_2._jspService(_0002fjsp_0002fTestPolyMorph_0002ejspTestPolyMorph_jsp_2.java:91)

   at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at

org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)

   at

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)

   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at

org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)

   at org.apache.tomcat.core.Handler.service(Handler.java:286)
   at
  org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)

   at

org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)

   at
  org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)

   at
  org.

apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)

   at

org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)

   at

org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)

   at java.lang.Thread.run(Thread.java:484)

  Root cause:
  org.apache.jasper.JasperException: 3.2
   at

org.apache.jasper.runtime.JspRuntimeLibrary.convert(JspRuntimeLibrary.java:138)

   at

org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(JspRuntimeLibrary.java:198)

   at

org.apache.jasper.runtime.JspRuntimeLibrary.introspect(JspRuntimeLibrary.java:152)

   at
  jsp._0002fjsp_0002fTestPolyMorph_00

02ejspTestPolyMorph_jsp_2._jspService(_0002fjsp_0002fTestPolyMorph_0002ejspTestPolyMorph_jsp_2.java:91)

   at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at

org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)

   at

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)

   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at

org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)

   at org.apache.tomcat.core.Handler.service(Handler.java:286)
   at
  org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)

   at

org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)

   at
  org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)

   at
  org.

apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)

   at

org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)

   at

org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)

   at java.lang.Thread.run(Thread.java:484)

  Even though there is indeed a method signature:
  setNumberVar(String i);
  ....
  Tomcat prefers to use (through introspection):
  setNumberVar(int i);

  The beans I use to handle property settings must continue to use
  polymorphism.

  Any ideas?

  Thanks,

  matt


Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message