I have a list of constant values which are stored in a database table. My application's search form is generated by a common include file which can be placed in any JSP page on the site. This search form should include the constants from the database table. A Spring bean manages the database layer and I'm having trouble finding an appropriate place to load the constants from. I have tried the following:
- Using a static method to load the constants. The problem with this technique is that a static method cannot access the Spring bean used to access the database.
- Loading the constants in the base action class. This would cause the database to be queried for the constants on each page load. I could reduce the performance penalty slightly by saving the results in each user's session, but that is not ideal.
- Creating a global spring bean with the constants. I don't know how I would be able to access this global class from the include file though.
Is there another option that I'm overlooking? I would like to be able to cleanly retrieve the constants from the include file.