You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ludwig Magnusson <lu...@itcatapult.com> on 2009/11/23 18:24:04 UTC

Problems finding the right filepath

Hello!

We are a team developing a webapp running on a tomcat server. We need to
list the files in a certain directory in our application, but we cannot find
a way to always get the correct path on the different platforms and
environments. Is this solvable through some IO-function or do we need to
specify the path to our project in each environment?

/Ludwig

 


RE: Problems finding the right filepath

Posted by Joseph Morgan <jo...@ignitesales.com>.
Ludwig,

What is your dev language? 

-----Original Message-----
From: Ludwig Magnusson [mailto:ludwig@itcatapult.com] 
Sent: Monday, November 23, 2009 11:24 AM
To: users@tomcat.apache.org
Subject: Problems finding the right filepath

Hello!

We are a team developing a webapp running on a tomcat server. We need to
list the files in a certain directory in our application, but we cannot
find
a way to always get the correct path on the different platforms and
environments. Is this solvable through some IO-function or do we need to
specify the path to our project in each environment?

/Ludwig

 


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


RE: Problems finding the right filepath

Posted by Ludwig Magnusson <lu...@itcatapult.com>.
I want to index all my screen templates for a url-rewrite feature.
/Ludwig

-----Original Message-----
From: Pid [mailto:pid@pidster.com] 
Sent: den 23 november 2009 20:03
To: users@tomcat.apache.org
Subject: Re: Problems finding the right filepath

On 23/11/2009 18:41, Ludwig Magnusson wrote:
> Thank you, that one worked.
> /Ludwig

May I ask what you're searching for?


p

> -----Original Message-----
> From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com]
> Sent: den 23 november 2009 19:25
> To: Tomcat Users List
> Subject: RE: Problems finding the right filepath
>
> Ludwig, it's been a while, but there used to be a function "getRealPath"
> or something very close to that on the ServletContext object where you
> can get a system-proper path of a resource.  Have you tried that?
>
> -----Original Message-----
> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Sent: Monday, November 23, 2009 12:17 PM
> To: 'Tomcat Users List'
> Subject: RE: Problems finding the right filepath
>
> We are running Tomcat 6.0.20.
> The JDK is 1.6 but not the exact same version on all machines. My
> computer
> has 1.6.0.17, the server has 1.6.0.07
> We are developing on both windows and mac. The server is ubuntu.
>
> To specify what I want, here is a model of my filesystem:
>
> /Tomcat-folder
>     /conf
>     /webapps
>       /my-webapp
>         /WEB-INF
>            /web.xml
>         /my-folder<--- this is the folder I want to search
>
> If there is no specific way of solving this I can try the ones you have
> suggested.
> /Ludwig
>
> -----Original Message-----
> From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com]
> Sent: den 23 november 2009 19:02
> To: Tomcat Users List
> Subject: RE: Problems finding the right filepath
>
> Or... maybe within a initialization parameter for a servlet if you are
> using Java
>
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Sent: Monday, November 23, 2009 11:59 AM
> To: Tomcat Users List
> Subject: RE: Problems finding the right filepath
>
>> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
>> Subject: Problems finding the right filepath
>>
>> We are a team developing a webapp running on a tomcat server.
>
> What version of Tomcat?  (Be precise.)  What JVM?
>
>> We need to list the files in a certain directory in our
>> application, but we cannot find a way to always get the
>> correct path on the different platforms and environments.
>
> Can you let the DefaultServlet do it?  Directory listings are normally
> disabled, but you can enable them for your particular webapp if you wish
>
> Note that there is no requirement for a servlet container (e.g., Tomcat)
> to provide *any* access to the underlying file system (if there is one
> at all), other than to a scratch area for the webapp's internal use.  If
> your webapp is deployed as a .war file, there is no file structure to
> look at.
>
>> Is this solvable through some IO-function or do we need
>> to specify the path to our project in each environment?
>
> You will likely need to specify the path through an environment
> variable, Java system property, or within the webapp<Context>  element,
> via a nested<Parameter>  or<Environment>  setting.
>
>   - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> 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
>
>
> ---------------------------------------------------------------------
> 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
>
>
> ---------------------------------------------------------------------
> 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


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


Re: Problems finding the right filepath

Posted by Pid <pi...@pidster.com>.
On 23/11/2009 18:41, Ludwig Magnusson wrote:
> Thank you, that one worked.
> /Ludwig

May I ask what you're searching for?


p

> -----Original Message-----
> From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com]
> Sent: den 23 november 2009 19:25
> To: Tomcat Users List
> Subject: RE: Problems finding the right filepath
>
> Ludwig, it's been a while, but there used to be a function "getRealPath"
> or something very close to that on the ServletContext object where you
> can get a system-proper path of a resource.  Have you tried that?
>
> -----Original Message-----
> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Sent: Monday, November 23, 2009 12:17 PM
> To: 'Tomcat Users List'
> Subject: RE: Problems finding the right filepath
>
> We are running Tomcat 6.0.20.
> The JDK is 1.6 but not the exact same version on all machines. My
> computer
> has 1.6.0.17, the server has 1.6.0.07
> We are developing on both windows and mac. The server is ubuntu.
>
> To specify what I want, here is a model of my filesystem:
>
> /Tomcat-folder
>     /conf
>     /webapps
>       /my-webapp
>         /WEB-INF
>            /web.xml
>         /my-folder<--- this is the folder I want to search
>
> If there is no specific way of solving this I can try the ones you have
> suggested.
> /Ludwig
>
> -----Original Message-----
> From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com]
> Sent: den 23 november 2009 19:02
> To: Tomcat Users List
> Subject: RE: Problems finding the right filepath
>
> Or... maybe within a initialization parameter for a servlet if you are
> using Java
>
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Sent: Monday, November 23, 2009 11:59 AM
> To: Tomcat Users List
> Subject: RE: Problems finding the right filepath
>
>> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
>> Subject: Problems finding the right filepath
>>
>> We are a team developing a webapp running on a tomcat server.
>
> What version of Tomcat?  (Be precise.)  What JVM?
>
>> We need to list the files in a certain directory in our
>> application, but we cannot find a way to always get the
>> correct path on the different platforms and environments.
>
> Can you let the DefaultServlet do it?  Directory listings are normally
> disabled, but you can enable them for your particular webapp if you wish
>
> Note that there is no requirement for a servlet container (e.g., Tomcat)
> to provide *any* access to the underlying file system (if there is one
> at all), other than to a scratch area for the webapp's internal use.  If
> your webapp is deployed as a .war file, there is no file structure to
> look at.
>
>> Is this solvable through some IO-function or do we need
>> to specify the path to our project in each environment?
>
> You will likely need to specify the path through an environment
> variable, Java system property, or within the webapp<Context>  element,
> via a nested<Parameter>  or<Environment>  setting.
>
>   - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
>
> ---------------------------------------------------------------------
> 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
>
>
> ---------------------------------------------------------------------
> 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
>
>
> ---------------------------------------------------------------------
> 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: Problems finding the right filepath

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Subject: RE: Problems finding the right filepath
> 
> Thank you, that one worked.

Again, getRealPath() is not guaranteed to return anything - it's up to the whim of the container.  To quote from the API doc:

"This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive)."

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Problems finding the right filepath

Posted by Ludwig Magnusson <lu...@itcatapult.com>.
Thank you, that one worked.
/Ludwig

-----Original Message-----
From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com] 
Sent: den 23 november 2009 19:25
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

Ludwig, it's been a while, but there used to be a function "getRealPath"
or something very close to that on the ServletContext object where you
can get a system-proper path of a resource.  Have you tried that?

-----Original Message-----
From: Ludwig Magnusson [mailto:ludwig@itcatapult.com] 
Sent: Monday, November 23, 2009 12:17 PM
To: 'Tomcat Users List'
Subject: RE: Problems finding the right filepath

We are running Tomcat 6.0.20.
The JDK is 1.6 but not the exact same version on all machines. My
computer
has 1.6.0.17, the server has 1.6.0.07
We are developing on both windows and mac. The server is ubuntu.

To specify what I want, here is a model of my filesystem:

/Tomcat-folder
   /conf
   /webapps
     /my-webapp
       /WEB-INF
          /web.xml
       /my-folder <--- this is the folder I want to search

If there is no specific way of solving this I can try the ones you have
suggested.
/Ludwig

-----Original Message-----
From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com] 
Sent: den 23 november 2009 19:02
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

Or... maybe within a initialization parameter for a servlet if you are
using Java

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Monday, November 23, 2009 11:59 AM
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Subject: Problems finding the right filepath
> 
> We are a team developing a webapp running on a tomcat server.

What version of Tomcat?  (Be precise.)  What JVM?

> We need to list the files in a certain directory in our 
> application, but we cannot find a way to always get the
> correct path on the different platforms and environments.

Can you let the DefaultServlet do it?  Directory listings are normally
disabled, but you can enable them for your particular webapp if you wish

Note that there is no requirement for a servlet container (e.g., Tomcat)
to provide *any* access to the underlying file system (if there is one
at all), other than to a scratch area for the webapp's internal use.  If
your webapp is deployed as a .war file, there is no file structure to
look at.

> Is this solvable through some IO-function or do we need
> to specify the path to our project in each environment?

You will likely need to specify the path through an environment
variable, Java system property, or within the webapp <Context> element,
via a nested <Parameter> or <Environment> setting.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.


---------------------------------------------------------------------
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


---------------------------------------------------------------------
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


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


RE: Problems finding the right filepath

Posted by Joseph Morgan <jo...@ignitesales.com>.
Ludwig, it's been a while, but there used to be a function "getRealPath"
or something very close to that on the ServletContext object where you
can get a system-proper path of a resource.  Have you tried that?

-----Original Message-----
From: Ludwig Magnusson [mailto:ludwig@itcatapult.com] 
Sent: Monday, November 23, 2009 12:17 PM
To: 'Tomcat Users List'
Subject: RE: Problems finding the right filepath

We are running Tomcat 6.0.20.
The JDK is 1.6 but not the exact same version on all machines. My
computer
has 1.6.0.17, the server has 1.6.0.07
We are developing on both windows and mac. The server is ubuntu.

To specify what I want, here is a model of my filesystem:

/Tomcat-folder
   /conf
   /webapps
     /my-webapp
       /WEB-INF
          /web.xml
       /my-folder <--- this is the folder I want to search

If there is no specific way of solving this I can try the ones you have
suggested.
/Ludwig

-----Original Message-----
From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com] 
Sent: den 23 november 2009 19:02
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

Or... maybe within a initialization parameter for a servlet if you are
using Java

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Monday, November 23, 2009 11:59 AM
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Subject: Problems finding the right filepath
> 
> We are a team developing a webapp running on a tomcat server.

What version of Tomcat?  (Be precise.)  What JVM?

> We need to list the files in a certain directory in our 
> application, but we cannot find a way to always get the
> correct path on the different platforms and environments.

Can you let the DefaultServlet do it?  Directory listings are normally
disabled, but you can enable them for your particular webapp if you wish

Note that there is no requirement for a servlet container (e.g., Tomcat)
to provide *any* access to the underlying file system (if there is one
at all), other than to a scratch area for the webapp's internal use.  If
your webapp is deployed as a .war file, there is no file structure to
look at.

> Is this solvable through some IO-function or do we need
> to specify the path to our project in each environment?

You will likely need to specify the path through an environment
variable, Java system property, or within the webapp <Context> element,
via a nested <Parameter> or <Environment> setting.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.


---------------------------------------------------------------------
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


---------------------------------------------------------------------
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: Problems finding the right filepath

Posted by Ludwig Magnusson <lu...@itcatapult.com>.
We are running Tomcat 6.0.20.
The JDK is 1.6 but not the exact same version on all machines. My computer
has 1.6.0.17, the server has 1.6.0.07
We are developing on both windows and mac. The server is ubuntu.

To specify what I want, here is a model of my filesystem:

/Tomcat-folder
   /conf
   /webapps
     /my-webapp
       /WEB-INF
          /web.xml
       /my-folder <--- this is the folder I want to search

If there is no specific way of solving this I can try the ones you have
suggested.
/Ludwig

-----Original Message-----
From: Joseph Morgan [mailto:joseph.morgan@ignitesales.com] 
Sent: den 23 november 2009 19:02
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

Or... maybe within a initialization parameter for a servlet if you are
using Java

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Monday, November 23, 2009 11:59 AM
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Subject: Problems finding the right filepath
> 
> We are a team developing a webapp running on a tomcat server.

What version of Tomcat?  (Be precise.)  What JVM?

> We need to list the files in a certain directory in our 
> application, but we cannot find a way to always get the
> correct path on the different platforms and environments.

Can you let the DefaultServlet do it?  Directory listings are normally
disabled, but you can enable them for your particular webapp if you wish

Note that there is no requirement for a servlet container (e.g., Tomcat)
to provide *any* access to the underlying file system (if there is one
at all), other than to a scratch area for the webapp's internal use.  If
your webapp is deployed as a .war file, there is no file structure to
look at.

> Is this solvable through some IO-function or do we need
> to specify the path to our project in each environment?

You will likely need to specify the path through an environment
variable, Java system property, or within the webapp <Context> element,
via a nested <Parameter> or <Environment> setting.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.


---------------------------------------------------------------------
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


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


RE: Problems finding the right filepath

Posted by Joseph Morgan <jo...@ignitesales.com>.
Or... maybe within a initialization parameter for a servlet if you are
using Java

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: Monday, November 23, 2009 11:59 AM
To: Tomcat Users List
Subject: RE: Problems finding the right filepath

> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Subject: Problems finding the right filepath
> 
> We are a team developing a webapp running on a tomcat server.

What version of Tomcat?  (Be precise.)  What JVM?

> We need to list the files in a certain directory in our 
> application, but we cannot find a way to always get the
> correct path on the different platforms and environments.

Can you let the DefaultServlet do it?  Directory listings are normally
disabled, but you can enable them for your particular webapp if you wish

Note that there is no requirement for a servlet container (e.g., Tomcat)
to provide *any* access to the underlying file system (if there is one
at all), other than to a scratch area for the webapp's internal use.  If
your webapp is deployed as a .war file, there is no file structure to
look at.

> Is this solvable through some IO-function or do we need
> to specify the path to our project in each environment?

You will likely need to specify the path through an environment
variable, Java system property, or within the webapp <Context> element,
via a nested <Parameter> or <Environment> setting.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.


---------------------------------------------------------------------
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: Problems finding the right filepath

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Ludwig Magnusson [mailto:ludwig@itcatapult.com]
> Subject: Problems finding the right filepath
> 
> We are a team developing a webapp running on a tomcat server.

What version of Tomcat?  (Be precise.)  What JVM?

> We need to list the files in a certain directory in our 
> application, but we cannot find a way to always get the
> correct path on the different platforms and environments.

Can you let the DefaultServlet do it?  Directory listings are normally disabled, but you can enable them for your particular webapp if you wish

Note that there is no requirement for a servlet container (e.g., Tomcat) to provide *any* access to the underlying file system (if there is one at all), other than to a scratch area for the webapp's internal use.  If your webapp is deployed as a .war file, there is no file structure to look at.

> Is this solvable through some IO-function or do we need
> to specify the path to our project in each environment?

You will likely need to specify the path through an environment variable, Java system property, or within the webapp <Context> element, via a nested <Parameter> or <Environment> setting.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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