Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Problem with Cascading Dropdown List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with Cascading Dropdown List" Watch "Problem with Cascading Dropdown List" New topic
Author

Problem with Cascading Dropdown List

Mellisa Thenu
Greenhorn

Joined: Nov 15, 2007
Posts: 6
Hello,

I've been google-ing and searching for the answers to my problem but no luck so far.

I have a JSP application with MySQL database, and one of the form has cascading dropdown list. So here is how the page works. There are 2 dropdown list: Term List and Class List. When the page is loading, it will populate the term list from the database. Based on the user selection on the term, it will run the database query for the Class List to display a list of class under that selected term.

The dropdown list is working just fine. But after doing several selections, the page will just keep loading and the server just died.

Anybody has a suggestion of what could be the problem? Thank you so much for the help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

What's occurring when the first selection is made? Is the secondary dropdown's data obtained via an Ajax call, or a full-page submission? In either case, what's the logic around it?

Please post the relevant code. Be sure to use UBB code tags to preserve its formatting.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mellisa Thenu
Greenhorn

Joined: Nov 15, 2007
Posts: 6
Thank you for the fast response. I am not using AJAX call, so it is a full-page submission. Here is the code for that:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Oh my. I would be remiss if I didn't point out that putting Java code in JSP pages in this way -- especially JDBC code -- is considered an egregious violation of best practices.

Please describe the exact behavior you are seeing.
Mellisa Thenu
Greenhorn

Joined: Nov 15, 2007
Posts: 6
I am new to JSP so I do not know the best practice for this.

The page will work just fine for the first or second time of selection. For example:

First attempt:
I select the term --> the Class list is populated correctly.

Second attempt:
I re-select the term --> the Class list is still populated correctly.

Usually, after the fourth or fifth attempt, the page will just keep loading and there is nothing I can do unless restarting the server.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Is there JavaScript code that you haven't shown us that controls the submission?
Mellisa Thenu
Greenhorn

Joined: Nov 15, 2007
Posts: 6
There is no JavaScript code for that.

After doing more research, I just changed the maxActive value for the database connection to 100 (it was 8 before), and now everything is working. I have done a lot of selection attempts and so far the site is still up.

My question now: is this just a temporary fix or not? Will this create another problem?

Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Sounds like that limit was causing an exception that was causing the issue. You might want to review your exception handling and logging to prevent a recurrence.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

Going forward, I would also recommend becoming familiar with better ways to structure your code so that debugging such issues is much easier.

You my find this article a good place to start.
Mellisa Thenu
Greenhorn

Joined: Nov 15, 2007
Posts: 6
I'll take a look on that. Thank you so much for your help .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Cascading Dropdown List