Problem using dynamic variable as HashMap key

S

Stan Kulp

I have created a HashMap called instantHashMap and loaded it with data from
a query .

I can load a variable with an explicit value for the HashMap key and
successfully output the HashMap value:

<c:set var = "gameno" value="2" />
<c:eek:ut value = "${instantHashMap[gameno]}" />

But when I load my variable value from my data like this...

<c:set var = "gameno" value="${rvo.gameNo}" />
<c:eek:ut value = "${instantHashMap[gameno]}" />

....it doesn't work.

My loaded variable value is correct because this statement does work and
reflects the data obtained from my query:

<c:eek:ut value = "${gameno}" />

I have determined that the hashmap key must be a string because if I change
the original statement

<c:set var = "gameno" value="2" />

to

<c:set var = "gameno" value="${ 1 + 1 }" />

this statement

<c:eek:ut value = "${gameno}" />

prints a 2, but the statatement

<c:eek:ut value = "${instantHashMap[gameno]}" />

now fails.

The database data type of my gameno field is varchar, so Java should see it
as a string.

What am I doing wrong?
 
C

Chris Smith

Stan Kulp said:
<c:set var = "gameno" value="${rvo.gameNo}" />
<c:eek:ut value = "${instantHashMap[gameno]}" />

...it doesn't work.

I have determined that the hashmap key must be a string [...]


So what is the type of the gameNo property of the rvo bean. Note that
database types are irrelevant here. We're looking for where "rvo" comes
from, and the type of its gameNo property according to the JavaBeans
spec.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top