db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hassan Abolhassani <Hassan.Abolhass...@razorfish.co.jp>
Subject Re: Web Applications
Date Tue, 27 Jan 2004 06:32:47 GMT
>Hey everybody, st00pid newbie here... I've gone through the torque 
>tutorial successfully and experimented a bit beyond it but now I'm 
>trying to use torque in a web application for the first time and have 
>run into some trouble.  I'm confused about the Torque.properties file 
>and the init() method.  I've placed the Torque.properties file in the 
>root of my .war, in WEB-INF/, WEB-INF/classes, WEB-INF/lib, just about 
>everywhere, but when I call init("Torque.properties") it can't find it. 
>  Where is it supposed to live and how do I reference it?  

My solution is to have an initializer servlet. It passes a phycial path
of the properties file to the init(). Attached is a copy of that servlet
that might be usefull for you. 

You need to make it called when the servlet engine is started. To do
that the following snippet in web.xml of your application will work:





Please note that the servlet also initializes log4j, which you may want
to ignore it.

>Also, do I 
>call init() in each class that uses Torque or do I need to somehow only 
>call it once when the web app is deployed?  Sorry if this is a dumb 
>question, but I can't find anything in the docs to help me.  Thanks 

You only need to call init() one time.

--Travis Hanna


Razorfish Japan, Inc.

アボルハッサニ ハッサン   Hassan Abolhassani  [Technology network]
株式会社 レーザーフィッシュ・ジャパン
Tel:03-5436-9980 Fax:03-5436-9126

View raw message