> 4) Put the torque.properties file in a path outside of my
> web-app, and pass my InitServlet the absolute path to that
> file. This took the guesswork out of trying to figure out
> where that file should go. Like was said earlier, it will
> either work or it won't, but you'll know it's not where the
> file should go that's breaking.
>
If you want to use Torque.properties file from within your WEB-INF
directory, you can do that, but you have to use the getResourceAsStream
function, not getRealPath.
Here is how my InitTorque servlet looks like:
public class InitTorque extends HttpServlet {
/** Initializes Torque
* @param config servlet configuration
* @throws ServletException if error occurs
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
InputStream configStream =
getServletContext().getResourceAsStream(
config.getInitParameter("config") );
PropertiesConfiguration c = new PropertiesConfiguration();
c.load( configStream );
Torque.init( c );
}
catch ( IOException e ) {
throw new ServletException( e.toString() );
}
catch ( TorqueException e ) {
throw new ServletException( e.toString() );
}
}
}
and web.xml:
<servlet>
<servlet-name>InitTorque</servlet-name>
<servlet-class>InitTorque</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/Torque.properties</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
Cheers,
Rafal
--
To unsubscribe, e-mail: <mailto:turbine-torque-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:turbine-torque-user-help@;jakarta.apache.org>