Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Bean not functioning as expected.  RSS feed

 
Charessa Reilly
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I have a JSP running the following script section.


irCollection has an ArrayList property that stores a several InquireRecord objects. It gets this data from a database using the mgrid as (set in line 2 there) as the matching term.

But I'm getting an IndexOutOfBounds exception on what appears here as line 11.

I've done some tests, and I'm pretty sure that it's because populateCollection() isn't getting things done. I have a getSize method that gives me a size of 0.

I made a test class in Eclipse to make sure all my methods were working:

That test class produces exactly what I'd expect.
Other than the names of some of the local variables, I can't see what I'm doign different in the JSP.

So... tell me, what noobish mistake did I make?

for the sake of being thorough, here's the populateCollection() method:

 
Charessa Reilly
Ranch Hand
Posts: 39
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the record, what coderanch is doing to my line 5 in the last bit of code is more than a little irritating.

That line should read:

String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
 
Stefan Evans
Bartender
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing, check your log/output for any exceptions.
You're catching and swallowing all Exceptions in your populateCollection method.


A size of 0 means one of two things to me
1 - your query returns no results
2 - an exception is being thrown and it never gets around to setting the size attribute.

Next thing it might be is that you are asking for a record greater than the current number of records retrieved.
You are calling getCurRecords in a loop which loops 10 times. What happens when there are less than 10 records retrieved?

Also, scriptlet code in JSP is discouraged.



EDIT:
P.S.: Thanks for pointing out the issue with the automatic replacement in your code. It has been raised with the appropriate authorities who have the power to fix such things
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!