I was programming in a similar situation about a year ago, and I found
the concept of application scope very useful.

Basically, the first time the application scope object is initialized,
it retrieves the information from the database and then stores it.
Whenever any further access is requires, it is performed to the object
not the database.

The tricky part comes, when the database contents change. This depends
on how possible changes can occur. If the database can only be modified
from within the JSP pages, then simply any JSP that modifies it, should
either mark the object as 'dirty' and force it to reinitialize the data,
or mark it null (there are different implications of both).

If the data can be modified externally of the JSP, then you have
potentially a problem. Unless you can have a threaded class which
periodically monitors the database for changes, or link up anything that
can possibly modify the database to notify your running program you may
have problems.

Hope this helps anyway,

Best regards,
Peter Dolukhanov

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]] On Behalf Of Jerson Chua
Sent: 12 December 2002 21:48
To: [EMAIL PROTECTED]
Subject: Data Caching

Hi,
I have several drop down list in my JSP pages and their values are
retrieved from the database everytime the page is requested. I found
this approach to be inefficient so I'm thinking of implementing a cache
for the drop down values.
My question is what's the best design pattern/architecture that I can
use to implement the caching mechanism? How would I be able to know if
some changes were made on the database? How are guys handling this
scenario?

Thanks.

Jerson

========================================================================
===
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to