You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by VIKASS NAGPAL <vi...@yahoo.com> on 2006/04/21 00:45:10 UTC

Properties file problem

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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Properties file problem

Posted by Tim Lucia <ti...@yahoo.com>.
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:vikassn@yahoo.com] 
Sent: Tuesday, April 25, 2006 12:07 PM
To: Tomcat Users List; hadrabap@bluetone.cz
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 <ha...@bluetone.cz> 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 <vi...@yahoo.com> 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:
> users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail:
> users-help@tomcat.apache.org
> >
> >
> 
> 
> --
> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Properties file problem

Posted by VIKASS NAGPAL <vi...@yahoo.com>.
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 <ha...@bluetone.cz> 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 <vi...@yahoo.com> 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:
> users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail:
> users-help@tomcat.apache.org
> >
> >
> 
> 
> --
> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Properties file problem

Posted by Hadraba Petr <ha...@bluetone.cz>.
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 <vi...@yahoo.com> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


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

Re: Properties file problem

Posted by Marc Farrow <ma...@gmail.com>.
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 <vi...@yahoo.com> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


--
Marc Farrow

Re: multiple service tags in server.xml

Posted by Rumpa Giri <gi...@yahoo.com>.
I am new to this forum, it won't happen again. Thanks for reminding me.

Thanks again,
Rumpa Giri

Mark Thomas <ma...@apache.org> wrote: When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. To many of the list archiving services and mail clients
used by list subscribers this  makes your new message appear as part
of the old thread. This makes it harder for other users to find
relevant information when searching the lists.

This is known as thread hijacking and is behavior that is frowned
upon on this list. Frequent offenders will be removed from the list.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.

The correct procedure is to create a new message with a new subject.
This will start a new thread.

Mark
tomcat-user-owner


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

Re: multiple service tags in server.xml

Posted by Mark Thomas <ma...@apache.org>.
When starting a new thread (ie sending a message to the list about a
new topic) please do not reply to an existing message and change the
subject line. To many of the list archiving services and mail clients
used by list subscribers this  makes your new message appear as part
of the old thread. This makes it harder for other users to find
relevant information when searching the lists.

This is known as thread hijacking and is behavior that is frowned
upon on this list. Frequent offenders will be removed from the list.
It should also be noted that many list subscribers automatically
ignore any messages that hijack another thread.

The correct procedure is to create a new message with a new subject.
This will start a new thread.

Mark
tomcat-user-owner


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


multiple service tags in server.xml

Posted by Rumpa Giri <gi...@yahoo.com>.
I am going through the the documentation on configuring tomcat, and it mentions that in the server.xml I can have multiple service tags with different connectors.

Under what kind of circumstances, is this kind of configuration useful? having multiple <service> each with different connector port conifgured?


Thanks,
Rumpa

		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.