Background
Developing a simple web application (Eclipse + JBoss + Apache Tomcat) to generate XML files.
Problem
The "Business Area" list queries against the database, and the "Column Cluster" list queries the database using the selected "Business Area" items. Both of these are unique queries that are stored external text files.
The files are currently stored in the following locations:
- WebContent/META-INF/business-areas.sql
- WebContent/META-INF/column-clusters.sql
These are then used to seed PreparedStatement
s.
Source Code
The method to read the SQL code might resemble:
private String getSQL() {
String result = "";
try {
BufferedReader br = open( "business-areas.sql" );
String line = null;
while( (line = br.readLine()) != null ) {
result += line;
}
br.close();
}
catch( Exception e ) {
e.printStackTrace();
}
return result;
}
Questions
I would like to know:
- What are the best practices for storing such assets for deployment as part of a web app? (That is, is
META-INF
a good location, or isMETA-INF/resources
preferred?) - What APIs would you recommend for reading the file content? (That is, how do I write the
open
method so that it finds the files to open?)
I already have JNDI in place to establish the database connection, but would rather not use JNDI to obtain handles to the files, if possible.
Related Sites
- http://blogs.oracle.com/alexismp/entry/web_inf_lib_jar_meta
- http://www.avajava.com/tutorials/lessons/where-do-i-put-resources-in-my-maven-project.html
- http://docs.jboss.org/jbossweb/3.0.x/config/context.html
- http://tomcat.apache.org/tomcat-4.0-doc/catalina/docs/api/org/apache/naming/resources/FileDirContext.html
Thank you!