I've been trying out my web-app on different JSP engines and have found
a discrepancy between the way custom tags are handled on Orion 0.9 beta
versus JRun 3.0 beta. Orion behaved the way I expected, but when I tried
to find out from the JSP spec the way this situation should be handled,
I didn't find a clear answer.
I defined a custom tag class with an integer property, width, which I
then set as an attribute with an integer value in my JSP page. Orion
implicitly converted the string value to an integer, but JRun complained
that my class didn't have a setWidth(String) method. Apparently it only
handles tag properties that are strings.
I was expecting custom tag attributes to be handled like the way
<jsp:setProperty> handles properties. Table 2.4 in Section 2.13.2 of the
JSP 1.1 spec specifies the conversions that setProperty does from string
values to primitive types.
Section 2.12.1 talks about attribute values, but didn't clarify this
issue for me. Presumably I could use the syntax <my:tag width="<%= 87
%>" />, but this is obviously much less desirable, and more obscure,
than just writing width="87".
Can anyone tell me whether I'm off base in expecting to be able to do
just that?
Yours, JonTom
JT Kittredge
ITA Software
Cambridge, Massachusetts
Here the particulars of my tag.
ImageTag.java:
public class ImageTag extends TagSupport
{
...
public final int getWidth() {
return mWidth;
}
public void setWidth(int value) {
mWidth = value;
}
protected int mWidth;
....
}
cvgtags.tld:
<tag>
<name>img</name>
<tagclass>ITA.cvg.tags.ImageTag</tagclass>
<bodycontent>empty</bodycontent>
...
<attribute>
<name>width</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
login.jsp:
<cvg:img src="/images/logo.gif" width="87" height="67"/>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets