RE: Properties file problem

2006-04-25 Thread Tim Lucia
Hardwiring a directory inside a war's web.xml will likely get you into
portability problems.  If you must do this, at least make it a JNDI lookup
so that the JNDI provider (Tomcat, other app server) can manage this
resource -- that is, the person deploying the app has some flexibility in
where to put the file(s).

Tim
 

-Original Message-
From: VIKASS NAGPAL [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 25, 2006 12:07 PM
To: Tomcat Users List; [EMAIL PROTECTED]
Subject: Re: Properties file problem

Hi All,

I think the problem can be resolved by creating the temporary directory,
anyother directory which location can be hard-wired as initial parameter in
the web.xml file. But where in my application's web.xml I have to
hard-wire this directory. Can you please let me exactly where should I
hard-wire this directory so that my application can dynamically create the
properties file inside this directory.

Thanks,
Vikas Nagpal.


--- Hadraba Petr [EMAIL PROTECTED] wrote:

 Hi Vikas,
 
 some details:
 
 I see you're correctly using the
 getClass.getResource() (I'm using
 getServletContext().getResourceAsStream() or 
 getServletContext().getResource()). But, Why are you creating 
 resources? You see all the war content in the host OS filesystem 
 because of unpackWars=true. This is because of performance (I hope) 
 and if you set this to false, Tomcat will *read* resources (also 
 classes and anything else) from the WAR file directly! You are mixing 
 two things together: one are resources (they are using URL instead of
 File) and on the other side Host OS FileSystem (the File objects).
 
 So, you store database connection parameters in the property file. I 
 see two options to solve your problem:
 1. Move the property file outside the resources if you want dynamic 
 creation. For example: temporary directory, any other directory which 
 location can be hard-wired as initial parameter in the web.xml file.
 2. Use Tomcat's database pooler. You give more performence (if you're 
 not using your own database connection pooler)!
 
 
 Please explain what you want to do, what's your goal...
 
 Have a nice day
 
 PETR
 
 
 On 4/21/06, VIKASS NAGPAL [EMAIL PROTECTED] wrote:
  Hi All,
 
  I have a problem here. I have Pproperties file.
  It has the following code:
 
  File f = new File(propertyFolder);
 
  if (!f.exists()) f.mkdir();
 
  f = new File(propertyFolder +
  System.getProperty(file.separator) + propertyFileName);
 
  if (!f.exists())
  {
  String s = ((this.getClass().getResource(/ + 
  propertyFileName)).toString());
 
  File pf = new File(s.substring(6));
 
  This code creates a folder with the name propertiespaydir and file 
  with the name pdr.properties. In order to connect to the
 database i
  have to read the Servername, Database name,
 Username
  and password from this file or creates a file with
 the
  name pdr.properties file. But If i rename this pdr.properties file 
  to something else then my code does not create the file with the 
  name
 pdr.properties.
  So I cannot connect to the database. So anyone of
 you
  knows what change should i make into my existing
 code
  in order for me to create the file with the name pdr.properties in 
  case it does not exist. I would really be thankful for any help in 
  this matter.
 
  Thanks,
  With regards,
  Vikas Nagpal.
 
 
  __
  Do You Yahoo!?
  Tired of spam?  Yahoo! Mail has the best spam
 protection around
  http://mail.yahoo.com
 
 

-
  To unsubscribe, e-mail:
 [EMAIL PROTECTED]
  For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 
 
 
 --
 Petr Hadraba
 graphic artist and software designer
 http://people.hadraba-soft.com/~petr
 hadrabap AT bluetone DOT cz
 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Properties file problem

2006-04-21 Thread Marc Farrow
I am sorry, but I do not know what you are trying to do.  The best place for
this type of question would be on a Java list.  This is a list specific to
Tomcat issues.

On 4/20/06, VIKASS NAGPAL [EMAIL PROTECTED] wrote:

 Hi All,

 I have a problem here. I have Pproperties file.
 It has the following code:

 File f = new File(propertyFolder);

 if (!f.exists()) f.mkdir();

 f = new File(propertyFolder +
 System.getProperty(file.separator) +
 propertyFileName);

 if (!f.exists())
 {
 String s = ((this.getClass().getResource(/ +
 propertyFileName)).toString());

 File pf = new File(s.substring(6));

 This code creates a folder with the name
 propertiespaydir and file with the name
 pdr.properties. In order to connect to the database i
 have to read the Servername, Database name, Username
 and password from this file or creates a file with the
 name pdr.properties file. But If i rename this
 pdr.properties file to something else then my code
 does not create the file with the name pdr.properties.
 So I cannot connect to the database. So anyone of you
 knows what change should i make into my existing code
 in order for me to create the file with the name
 pdr.properties in case it does not exist. I would
 really be thankful for any help in this matter.

 Thanks,
 With regards,
 Vikas Nagpal.


 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




--
Marc Farrow


Re: Properties file problem

2006-04-21 Thread Hadraba Petr
Hi Vikas,

some details:

I see you're correctly using the getClass.getResource() (I'm using
getServletContext().getResourceAsStream() or
getServletContext().getResource()). But, Why are you creating
resources? You see all the war content in the host OS filesystem
because of unpackWars=true. This is because of performance (I hope)
and if you set this to false, Tomcat will *read* resources (also
classes and anything else) from the WAR file directly! You are mixing
two things together: one are resources (they are using URL instead of
File) and on the other side Host OS FileSystem (the File objects).

So, you store database connection parameters in the property file. I
see two options to solve your problem:
1. Move the property file outside the resources if you want dynamic
creation. For example: temporary directory, any other directory which
location can be hard-wired as initial parameter in the web.xml file.
2. Use Tomcat's database pooler. You give more performence (if you're
not using your own database connection pooler)!


Please explain what you want to do, what's your goal...

Have a nice day

PETR


On 4/21/06, VIKASS NAGPAL [EMAIL PROTECTED] wrote:
 Hi All,

 I have a problem here. I have Pproperties file.
 It has the following code:

 File f = new File(propertyFolder);

 if (!f.exists()) f.mkdir();

 f = new File(propertyFolder +
 System.getProperty(file.separator) +
 propertyFileName);

 if (!f.exists())
 {
 String s = ((this.getClass().getResource(/ +
 propertyFileName)).toString());

 File pf = new File(s.substring(6));

 This code creates a folder with the name
 propertiespaydir and file with the name
 pdr.properties. In order to connect to the database i
 have to read the Servername, Database name, Username
 and password from this file or creates a file with the
 name pdr.properties file. But If i rename this
 pdr.properties file to something else then my code
 does not create the file with the name pdr.properties.
 So I cannot connect to the database. So anyone of you
 knows what change should i make into my existing code
 in order for me to create the file with the name
 pdr.properties in case it does not exist. I would
 really be thankful for any help in this matter.

 Thanks,
 With regards,
 Vikas Nagpal.


 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




--
Petr Hadraba
graphic artist and software designer
http://people.hadraba-soft.com/~petr
hadrabap AT bluetone DOT cz


Properties file problem

2006-04-20 Thread VIKASS NAGPAL
Hi All,

I have a problem here. I have Pproperties file.
It has the following code:

File f = new File(propertyFolder);

if (!f.exists()) f.mkdir();

f = new File(propertyFolder +
System.getProperty(file.separator) +
propertyFileName);

if (!f.exists())
{
String s = ((this.getClass().getResource(/ +
propertyFileName)).toString());

File pf = new File(s.substring(6)); 

This code creates a folder with the name
propertiespaydir and file with the name
pdr.properties. In order to connect to the database i
have to read the Servername, Database name, Username
and password from this file or creates a file with the
name pdr.properties file. But If i rename this
pdr.properties file to something else then my code
does not create the file with the name pdr.properties.
So I cannot connect to the database. So anyone of you
knows what change should i make into my existing code
in order for me to create the file with the name
pdr.properties in case it does not exist. I would
really be thankful for any help in this matter.

Thanks,
With regards,
Vikas Nagpal.   


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]