tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glenn Atter" <>
Subject Tags with primitive variables.
Date Tue, 07 Dec 1999 13:27:53 GMT
Hi Folks,

I have been using the taglibrary functionality of Jakarta for about 1 month.
I have developed quite a few tags (~10). One of these tags is a for loop
tag, i.e.

<for id="i" start="1" end="20">
	Item number <%=i%>

Currently the variable nested inside the for tag is an java.lang.Integer
Object. This is fine for general usage as show above but if I wanted to use
the variable in an equation I have to remember to use the intValue() method,

<for id="i" start="1" end="20">
	Item number <%=i.intValue() * 100%>

As our customers will be using these tags I can see this becoming very
complicated for them. However, this would not be a problem if we could
return primitive types from the tags, in this case an int. I have looked
into the problem and implementing this would mean a change to the
TagGeneratorBase.declareVariables() method.

If the className is a primitive type, i.e. int, double, float etc. then it
should output something like the following

int i = ((Integer) pageContext.getAttribute("i")).intValue();


double d = ((Double) pageContext.getAttribute("d")).doubleValue();

I know that this requires that the object used in the setAttribute call
within the Tag to be the appropriate java.lang object for the primitive data

I also appreciate that this change would probably go against the current JSP
specification but it would greatly simplify the usage of these types of

If anyone has a workaround that does not require any changes to Jakarta I
would really like to hear from you. Otherwise, am I expecting too much for
this type of change to be made to Jakarta.



View raw message