db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andras Balogh <and...@reea.net>
Subject Re: Torque and jsp
Date Tue, 15 Mar 2005 14:48:18 GMT
Hello,

    Why don't You put the torque.properties file in WEB-INF/classes/ and 
load it like this:
if(!Torque.isInit())
{
                PropertiesConfiguration pc = new PropertiesConfiguration();
                pc.load( 
this.getClass().getClassLoader().getResourceAsStream("torque.properties") );
               
                Torque.init(pc);
 }
    This way You don't have to hardcode any path and it will work on any 
deployment.
I use this  in a Servlet but I don't see why it wouldn't work in a jsp too.

Best regards,
Andras.


raphael.x.mankin@gsk.com wrote:

>Torque.init() requires an absolute pathname. It's a bummer.
>
>I put the true pathname in another properties file so that I do not have to
>hard-code it in the program. This does mean, however, that I have to know
>the absolute path where, in my case, Tomcat is installed. Here is my
>initialisation code
>
>        apiResources = ResourceBundle.getBundle("betapi");
>        if (!Torque.isInit()) {
>            String configFile = apiResources.getString
>("betapi.torqueconfig");
>            try {
>                Torque.init(configFile);
>            } catch (TorqueException e) {
>                  context.log(e,"Cannot initalise Torque: " + e.toString()
>);
>                e.printStackTrace(System.err);
>                System.exit(1);
>            }
>        }
>
>and betapi.properties contains:
>      betapi.torqueconfig=
>/users/rxm1676/workspace/pmfeditor/WEB-INF/classes/Torque.properties
>
>
>In cases where I build on one machine but run on another I have a little
>shell script that that runs on installation. It tracks down the appropriate
>line in betapi.properties and adjusts it so suit where the code is actually
>installed.
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message