Chris Tucker wrote:
> [...]
> I'm probably missing something very obvious here, but it's got me flummoxed
> right now.  I'm running Tomcat 4.01, JDK 1.3.1_01, and I'm having trouble
> with exceptions when trying to read Bean properties:
>
> 2001-12-06 09:52:24 StandardWrapperValve[jsp]: Servlet.service() for servlet
> jsp threw exception
> org.apache.jasper.JasperException: Cannot find a method to read property
> 'carYear' in a bean of type 'QuoteCalculationBean'
>
> I've been having this problem in an intermittent fashion within this
> particular Bean (not seen it in others => almost certainly my fault!) on
> various different properties.  There are appropriate get/set methods for the
> properties it can't find.  In the case of carYear they are:
> int getCarYear();
> void setCarYear(int v);
> void setCarYear(String v);
> [...]

The problem is likely that you have multiple setter methods for the
property with different types. This is admittedly a gray area of the
bean spec, but discussions I've had with the bean spec leads (as well as
the implementation of the bean classes) makes it clear that this is a
no-no; a property can only have one type, hence only one setter method.

If all you want is being able to set the property to an int (using a JSP
expression) or a static string representing a number, define the property
as an int. The container takes care of the convertion from String to
int automatically. If you use JSP 1.2, you can also use PropertyEditor
to define conversions from String values to any Java type. See my JSP 1.2
article for details:

  <http://www.onjava.com/pub/a/onjava/2001/11/07/jsp12.html>

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to