NEVER MIND. I was wrong about how <%= %> reads the + operator in this case. The problem is that the value is an Integer rather than an int. I learn something everyday.

At 10:38 AM 2/26/2004, you wrote:
The "+" operator is an overloaded operator in Java. Here, within <%= %> it thinks it is supposed to be concatenating and not adding. So, it cannot be applied to an integer in this case because that operator is being used to concatenate strings. I am going to assume that ctr is an integer. If so, the try the following:

<%= "" + (ctr + 1) %>

This will add the integers first with the second + operator, and then tell the first + operator for concatenation that you are dealing with strings by putting the "" first. You can also try:

<%= (ctr + 1) %>

But my suspicion is that the <%= %> stuff will have the same problem even without the operator, because the <%= %> will expect a string. The use of "" before the (ctr + 1) will signal the applicaiton to change the result of (ctr + 1) to a string for purposes of concatenation.

Anyway, something like that, I think.

Michael McGrady



At 09:13 AM 2/26/2004, you wrote:
Sorry, my mailer messed up the last one, so here again...

newbie question:

I have a jsp which displays several rows with a logic:iterate, also
using the indexId-tag.

<logic:iterate name="dateForm" property="raw" id="foo"
indexId="ctr" >

I'd like to display row numbers in my table. But the ctr-variable is 0-
based, and I would like to present 1 as the first number to my
users.

Now, this should work, isn't it??

<td><%= ctr + 1 %></td>

I would guess: ctr and 1 are added, and is then cast to a string, and
then printed in my table column.

Then why do i get this error?

operator + cannot be applied to java.lang.Integer, int [javac]
out.print( ctr + 1 );

It also does not work when I create a new variable with <%! int i=0;
%> , and then try to set this i as i = ctr + 1, same error.

So how can I get this row number printed in my table, inside the
jsp, as ctr + 1???


Rinke



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to