• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContext size constraints?

 
sylvia weller
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill -
Thanks for your helpful response.
Sylvia
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic