permaculture playing cards*
The moose likes Struts and the fly likes To load the data for the entire application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "To load the data for the entire application" Watch "To load the data for the entire application" New topic
Author

To load the data for the entire application

Brahmani Ganduri
Greenhorn

Joined: Dec 10, 2008
Posts: 17
Hi
For my web pages development using struts, I have an issue. We get the a list of 600 data from the database which is to be loaded in the application each time we call it. This is how it goes now.
But is there a way that the entire data can be loaded in the application at once and use the data wherever needed.
Balagopal Kannampallil
Ranch Hand

Joined: Oct 18, 2004
Posts: 136

Just a suggestion, try to group this 600 data into groups on basis of some fields preset in it. Pull the data based on the groups on a need to display basis so that you can reduce the load.


SCJP 5.0 and now fighting with ExtJS
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Brahmani Ganduri wrote:Hi
For my web pages development using struts, I have an issue. We get the a list of 600 data from the database which is to be loaded in the application each time we call it. This is how it goes now.
But is there a way that the entire data can be loaded in the application at once and use the data wherever needed.


600 db rows , is too big to walk with. If you do not care about the memory usage plus any performance impact, you can extend ContextListener class and store the rows(ResultSet object) in context scope..

If you memory is an issue, then do what Balagopal Kannampallil suggest.. Access them whenever they needed.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Brahmani Ganduri
Greenhorn

Joined: Dec 10, 2008
Posts: 17
I guess, I was not clear with my post. Let me be clear.

I am using a list of 600 cities for my index page. In my index page, there is a text box which works as an auto suggester with the 600 cities. Is there a way I can load the list of 600 cities (which i am getting from db)
JUST ONE TIME, into my jsps for the entire application. This will increase the performance of my index page.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1473
    
    6

Do you mean that once the data is loaded and after that if the page is refreshed it wont reload the data again?


Swastik
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Brahmani Ganduri wrote:I guess, I was not clear with my post. Let me be clear.

I am using a list of 600 cities for my index page. In my index page, there is a text box which works as an auto suggester with the 600 cities. Is there a way I can load the list of 600 cities (which i am getting from db)
JUST ONE TIME, into my jsps for the entire application. This will increase the performance of my index page.


This is the general thing a web designer face many time, when you need to develop page where a drop down contains name of country, states, what is and what not..

The general and simple technique is to place all the 600 cities in a JSP/HTML (<option>city</option>)page it self.. It won't cause any problem, provided the name of cities won't change frequently..
Brahmani Ganduri
Greenhorn

Joined: Dec 10, 2008
Posts: 17
Swastik Dey wrote:Do you mean that once the data is loaded and after that if the page is refreshed it wont reload the data again?


Hi
We are actually trying to get the list of stations, which match the first 3 letters of the station. We are using xmls for this, though ajax is a good one to do it.
Our issue is, once the stations are loaded in the application, they should not be reloaded or hit the database again.
Scope of the stations should be application. The station list is dynamic.

If any inputs on this, please reply.

Thanks all


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Brahmani Ganduri wrote:Is there a way I can load the list of 600 cities (which i am getting from db)
JUST ONE TIME


Use Singleton java class.For more detail google it
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Or put the list in application scope on startup.
Brahmani Ganduri
Greenhorn

Joined: Dec 10, 2008
Posts: 17
David Newton wrote:Or put the list in application scope on startup.


Thanks all for your replies.

David, we have actually tried to use the scope application also. But that was not working.
Now, we are trying to change the search pattern. As said, previously we were using xmls to get the station name which was performance issue.
Now, we are trying to use AJAX.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How can putting data into the application context "not work"?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

A context listener and application scope will work fine. If that's "not working" for you, you are doing it wrong.

Using Ajax for something like this would be ridiculous.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brahmani Ganduri
Greenhorn

Joined: Dec 10, 2008
Posts: 17
Bear Bibeault wrote:A context listener and application scope will work fine. If that's "not working" for you, you are doing it wrong.

Using Ajax for something like this would be ridiculous.


The station list is a drop down. and we are using the dropdown list wherever needed in the site. Application scope was not working.
Anyways, I will check again the whole code.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Brahmani Ganduri wrote:Application scope was not working.

So you just gave up instead of trying to find out why it was "not working"? (whatever that means)

Please read this for more information.
Brahmani Ganduri
Greenhorn

Joined: Dec 10, 2008
Posts: 17
Thank you, for your response.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: To load the data for the entire application