aspose file tools*
The moose likes Servlets and the fly likes ServletContext size constraints? 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 » Java » Servlets
Bookmark "ServletContext size constraints?" Watch "ServletContext size constraints?" New topic
Author

ServletContext size constraints?

sylvia weller
Greenhorn

Joined: Jan 07, 2002
Posts: 29
Hi -
I am writing an uncomplicated servlet-based application which queries one db table and retrieves a subset of its data for JSP/HTML display.
I was thinking about saving the entire table (a few thousand rows) to the ServletContext at application startup time. Then, subsequent retrievals could run against this saved version. I'm pretty sure this would be _much_ faster than doing dbio for each retrieval.
So here's my question - is there any reason not to save 'lots' of data - thousands of lines - on the ServletContext? and why? I actually don't know anything about how memory is allocated and how much is available, within the servlet container (tomcat in my case). I just naively came up with this idea and want to know if it was a bad or good one.
Also, if anyone knows of a good reference on this topic please let me know. Thanks.
Sylvia
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
I have never seen something like that done before, normally ServletContext is relatively small and restricted to parameters for a particular "web application".
If faced with the problem, I would keep the data as a static variable in the servlet class or as part of a "singleton" helper class. That would make it easier to regenerate if the database changed.
I think you should not try to keep the data as a ResultSet or other JDBC entity since that might hang on to additional resources. Instead, grab it to some convenient Java collection or write your own helper class to hold the data in some compact form.
Bill
sylvia weller
Greenhorn

Joined: Jan 07, 2002
Posts: 29
Hi Bill -
Thanks for your helpful response.
Sylvia
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletContext size constraints?