Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Problem using dynamic variable as HashMap key

Thread view: 
Stan Kulp - 16 Jun 2006 19:55 GMT
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:out value = "${instantHashMap[gameno]}" />

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

<c:set var = "gameno" value="${rvo.gameNo}" />
<c:out 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:out 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:out value = "${gameno}" />

prints a 2, but the statatement

<c:out 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?
Chris Smith - 18 Jun 2006 07:08 GMT
> <c:set var = "gameno" value="${rvo.gameNo}" />
> <c:out 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.

Signature

Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.