aspose file tools*
The moose likes JSP and the fly likes Error while setting values from a database to a drop down list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Error while setting values from a database to a drop down list" Watch "Error while setting values from a database to a drop down list" New topic
Author

Error while setting values from a database to a drop down list

Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
Hi all,

I have a JSP page with a drop down list that is to be populated with values from a database.

This is the code in my JSP file:



The DataManager.java class simply forwards this to its respective Peer class, which has the code shown below:




The classes compile properly, but when I load this page up in Tomcat it just freezes and does not load the form. I tested the DB connection and it works fine.

What am I doing wrong in the JSP code?

Thanks for the help in advance.

UPDATE: I commented out the form, and added <%=floornumbers.size()%> right above the commented code to check if the ArrayList is indeed getting populated with the values from the database (the values are of type integer in the database). The page still freezes like before. I'm puzzled now .
[ January 11, 2008: Message edited by: Sridhar Venkataraman ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Not sure if this is the problem but, is this what you really want?


Each call to iterator.next(), pops off the next value in the list.
So, if you had a list containing "1", "2", "3", "4", "5",
your options would look like:


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
Originally posted by Ben Souther:
Not sure if this is the problem but, is this what you really want?


Each call to iterator.next(), pops off the next value in the list.
So, if you had a list containing "1", "2", "3", "4", "5",
your options would look like:


Now that you've mentioned it, what I really wanted was:

<option value="1"> 1 </option>

and so on....

I can fix that easy. But why doesn't the code work? There seems to be no error with the DB connection or the query, and yet the page doesn't render.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Have you confirmed that nothing is coming from the server?

Sometimes, when looking at a blank screen, using the browser's view source feature shows that there is actually output but an error in the html keeps it from rendering.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Also, you haven't shown us the DataManager class or the code that instanciates it. Is there a useBean tag somewhere on the JSP?

Have you looked at your server's logs to see if any exceptions are being thrown?
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
Hi,

I have solved this issue. I did not use iterator in the right way, though it was only a shave
[ January 12, 2008: Message edited by: Bear Bibeault ]
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
Am I supposed to begin a new topic with the part of the message that was edited out?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61617
    
  67

Yes, and please do not move the conversation to another site and post links to it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sridhar Venkataraman
Ranch Hand

Joined: May 22, 2006
Posts: 76
All right. I participate in many forums, so I just thought it'd be easier this way.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while setting values from a database to a drop down list