Hi,
I was just wondering if you really have to use a physical configuration file
.....
I mean , If it were just for the information that you want from the outside ....
you can use the initArgs variable in your zone.properties file (if you are using
Apache and I am sure other servlet engines also have a configuration file wich
serve this purpose )
and have your servlet program read that variable for use.
The snippet goes like this ....
servlet.ServletClassName.initArgs=name=value;
and the Servlet code would be :
getServletConfig().getInitParameter("name");
That's just about it for something like passing your drivername,jdbc url etc.
And you can have multiple distinct name's name=value pairs in the configuration
files.
Hope that helps
Rishi.
PS - If you have all the reading of initialization parameters in the init section
code you can refer to it from all your instances .
YekSoon Lok wrote:
> Hi,
>
> I have code a servlet that can connect to the database.
> But I find my design not good enough.
>
> The main reason is because the connection string is coded
> inside. Should I change database or database instance,
> I would need to change the code and recompile the source.
>
> I'm thinking of putting the connection string in a text file
> and have my servlets access this file and read it in.
> This way all I need is to change the text file or initialization
> file and my class file remains the same.
>
> Does anyone have any snippets of code where I can learn how
> to read from a file ?
>
> Another area, is if I use a file for initilization purpose,
> I will have lots of sections. Examples are section for connection string,
> for constants (maybe) etc.
> Whats the best way to use a text file for init. purpose.
>
> Thanks
> ----------
> Message To Spammers -- Game Over! Get spam-free email at http://www.MsgTo.com
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html