This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes Retreiving more than 250 records everytime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Retreiving more than 250 records everytime" Watch "Retreiving more than 250 records everytime" New topic
Author

Retreiving more than 250 records everytime

Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
Hi,

I've written an application in JSTL where the user would need to update some regional settings. So I have a combo box where the user can selected the right country like:








The Method in the class looks like this:








The problem is I have several pages that do this and the user may try to do this several times. This will slow down the system as the user would need to retrieve the records every from the database all the time.

Is there a way I can this to be done only once and then save the List somewhere in memory?

Really appreciate it
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18712
    
    8

Of course. The country list is the same for all users and will never change? Then you could save it in the application scope.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Originally posted by Ali Khalfan:
I have a combo box ...

Correction: it's not a "combo box". That's a desktop control that is not available on the web. It's more correct to call it a "select" or a "dropdown".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ali Khalfan
Ranch Hand

Joined: Nov 03, 2007
Posts: 126
I apologize..yest it is a select

Paul, can you tell me how to save it in the application score I'd appreciate it
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

If it were me, I'd read in the values using a context listener, which would trigger once when the app is loaded. Then create the scoped variable in application scope using servletContext.setAttribute().
[ December 28, 2007: Message edited by: Bear Bibeault ]
 
Consider Paul's rocket mass heater.
 
subject: Retreiving more than 250 records everytime