You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Romain Quilici <r....@chem.usyd.edu.au> on 2006/08/09 04:09:34 UTC
getRealPath and war file
Hi all,
I know that this question has been asked many times, but still something
not clear for me.
When an application is deployed as a war file, (as mentioned in the
javadoc, or in several messages), context.getRealPath() will return null.
However, Tomcat creates automatically a directory under webapps to
contain war file contents, so I am wondering if Tomcat is using the
newly generated directory to load the application(1st case) or
the war file (2nd case).
In the first case context.getRealPath("/") should return the path to the
newly generated directory.
In the second case, why does Tomcat generate the directory to contain
war file contents?
Thanks for the explanation
Regards
Romain
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Dies Koper <di...@jp.fujitsu.com>.
> Push a url to a servlet which then serves the images from the working
> directory?
In which you could also set the headers (images are temporary, so maybe
set Cache-Control, Expires?).
Regards,
Dies
Mark Thomas wrote:
> Romain Quilici wrote:
>> Hello Dies,
>> the working directory would be fine, but my images need to be accessible
>> via a url(which is not the case if they are located inside the temp dir)
>> In fact when an image is generated, I push the url inside the client
>> browser, the new url automatically replaces the previous one in a
>> statement like <img src=.....>.
>> So I need a url to be able to access my images
>
> Push a url to a servlet which then serves the images from the working
> directory?
>
> Mark
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
Sorry,
in my previous message, I did not mean the working dir but the temp
dir(obtained with javax.servlet.context.tempdir).
Romain
Mark Thomas wrote:
> Romain Quilici wrote:
>
>> Hello Dies,
>> the working directory would be fine, but my images need to be accessible
>> via a url(which is not the case if they are located inside the temp dir)
>> In fact when an image is generated, I push the url inside the client
>> browser, the new url automatically replaces the previous one in a
>> statement like <img src=.....>.
>> So I need a url to be able to access my images
>>
>
> Push a url to a servlet which then serves the images from the working
> directory?
>
> Mark
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Mark Thomas <ma...@apache.org>.
Romain Quilici wrote:
> Hello Dies,
> the working directory would be fine, but my images need to be accessible
> via a url(which is not the case if they are located inside the temp dir)
> In fact when an image is generated, I push the url inside the client
> browser, the new url automatically replaces the previous one in a
> statement like <img src=.....>.
> So I need a url to be able to access my images
Push a url to a servlet which then serves the images from the working
directory?
Mark
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
Hello Dies,
the working directory would be fine, but my images need to be accessible
via a url(which is not the case if they are located inside the temp dir)
In fact when an image is generated, I push the url inside the client
browser, the new url automatically replaces the previous one in a
statement like <img src=.....>.
So I need a url to be able to access my images
Regards
Romain
Dies Koper wrote:
> Hello Romain,
>
> Is there no way you can use the temporary working directory
> (javax.servlet.context.tempdir)?
> I don't know what "pushing inside a client browser" means, but as you
> mentioned the files are temporary, this sounds like the place to put
> them..
> Also, you won't need to worry about maintaining some extra directory
> after deployment, and this is a portable solution.
>
> Regards,
> Dies
>
> Romain Quilici wrote:
>> Mikolaj Rydzewski wrote:
>>> Romain Quilici wrote:
>>>> My pb is more to write in a given directory(must be accessible with
>>>> a url), than to read.
>>>> And I would prefer this directory to be located in my webapp.
>>> Use directory outside webapp and then map it with alias, or some
>>> kind of dispatcher servlet/filter.
>>>
>>> It'll help you to redeploy webapp and not to loose uploaded/saved
>>> files.
>>>
>> Actually,
>> in my application, files are temporary. So even if they are deleted
>> in doesn't matter.
>> What I mean is images are pushed inside a client browser when they
>> are generated, but then are no longer used.
>> I prefer to create the directory within my application, to avoid
>> permissions issues
>> As I understood, context.getRealPath("/"); will return the context of
>> my application, even if my app is deployed within a war(as soon as
>> UnpackWars is set to true in Tomcat).
>> So I can deal with this command. I will provide anyway a mechanism to
>> check if context.getRealPath("/"); is null, in such case the
>> application should take the values from init parameters
>> Regards
>> Romain
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Romain,
Is there no way you can use the temporary working directory
(javax.servlet.context.tempdir)?
I don't know what "pushing inside a client browser" means, but as you
mentioned the files are temporary, this sounds like the place to put them..
Also, you won't need to worry about maintaining some extra directory
after deployment, and this is a portable solution.
Regards,
Dies
Romain Quilici wrote:
> Mikolaj Rydzewski wrote:
>> Romain Quilici wrote:
>>> My pb is more to write in a given directory(must be accessible with a
>>> url), than to read.
>>> And I would prefer this directory to be located in my webapp.
>> Use directory outside webapp and then map it with alias, or some kind
>> of dispatcher servlet/filter.
>>
>> It'll help you to redeploy webapp and not to loose uploaded/saved files.
>>
> Actually,
> in my application, files are temporary. So even if they are deleted in
> doesn't matter.
> What I mean is images are pushed inside a client browser when they are
> generated, but then are no longer used.
> I prefer to create the directory within my application, to avoid
> permissions issues
> As I understood, context.getRealPath("/"); will return the context of my
> application, even if my app is deployed within a war(as soon as
> UnpackWars is set to true in Tomcat).
> So I can deal with this command. I will provide anyway a mechanism to
> check if context.getRealPath("/"); is null, in such case the application
> should take the values from init parameters
> Regards
> Romain
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
Mikolaj Rydzewski wrote:
> Romain Quilici wrote:
>> My pb is more to write in a given directory(must be accessible with a
>> url), than to read.
>> And I would prefer this directory to be located in my webapp.
> Use directory outside webapp and then map it with alias, or some kind
> of dispatcher servlet/filter.
>
> It'll help you to redeploy webapp and not to loose uploaded/saved files.
>
Actually,
in my application, files are temporary. So even if they are deleted in
doesn't matter.
What I mean is images are pushed inside a client browser when they are
generated, but then are no longer used.
I prefer to create the directory within my application, to avoid
permissions issues
As I understood, context.getRealPath("/"); will return the context of my
application, even if my app is deployed within a war(as soon as
UnpackWars is set to true in Tomcat).
So I can deal with this command. I will provide anyway a mechanism to
check if context.getRealPath("/"); is null, in such case the application
should take the values from init parameters
Regards
Romain
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Romain Quilici wrote:
> My pb is more to write in a given directory(must be accessible with a
> url), than to read.
> And I would prefer this directory to be located in my webapp.
Use directory outside webapp and then map it with alias, or some kind of
dispatcher servlet/filter.
It'll help you to redeploy webapp and not to loose uploaded/saved files.
--
Mikolaj Rydzewski <mi...@ceti.pl>
Re: getRealPath and war file
Posted by Romain Quilici <r....@chem.usyd.edu.au>.
Mikolaj Rydzewski wrote:
> Romain Quilici wrote:
>> However, Tomcat creates automatically a directory under webapps to
>> contain war file contents, so I am wondering if Tomcat is using the
>> newly generated directory to load the application(1st case) or
>> the war file (2nd case).
>> In the first case context.getRealPath("/") should return the path to
>> the newly generated directory.
>> In the second case, why does Tomcat generate the directory to contain
>> war file contents?
> I.e. for performance reasons.
>
> One should use context.getResourceAsStream() to read files from both
> war or expanded directory.
>
Hi all,
thanks for the answer.
My pb is more to write in a given directory(must be accessible with a
url), than to read.
And I would prefer this directory to be located in my webapp.
Regards
Romain
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Romain Quilici wrote:
> However, Tomcat creates automatically a directory under webapps to
> contain war file contents, so I am wondering if Tomcat is using the
> newly generated directory to load the application(1st case) or
> the war file (2nd case).
> In the first case context.getRealPath("/") should return the path to
> the newly generated directory.
> In the second case, why does Tomcat generate the directory to contain
> war file contents?
I.e. for performance reasons.
One should use context.getResourceAsStream() to read files from both war
or expanded directory.
--
Mikolaj Rydzewski <mi...@ceti.pl>
Re: getRealPath and war file
Posted by Mark Thomas <ma...@apache.org>.
Romain Quilici wrote:
> However, Tomcat creates automatically a directory under webapps to
> contain war file contents, so I am wondering if Tomcat is using the
> newly generated directory to load the application(1st case) or
> the war file (2nd case).
If unpackWARs is true then the WAR is unpacked and the unpacked files
are used to load the application.
> In the first case context.getRealPath("/") should return the path to the
> newly generated directory.
To the best of my knowledge, it does.
> In the second case, why does Tomcat generate the directory to contain
> war file contents?
The directory is only generated if unpackWARs is true. Tomcat should
never, and doesn't as far as I am aware, unpack the WAR and the load
the app from the WAR.
You should also bear in mind that using antiJARLocking and/or
antiResourceLocking will also cause additional copies of files to be made.
HTH,
Mark
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: getRealPath and war file
Posted by Li <am...@gmail.com>.
Hi,
Most of j2ee application servers (tomcat, jboss) when a war or ear
file is deployed. It will generate a folder which contains the same
file structure (web application format) as which is in the war or ear
file.
A war is considered as a file but not a path. So if Tomcat only reads
war but not a directory based content, it has problem (when changes to
parent path, or changes to child path). Besides, a war is a packed jar
file, reading a directory based content is a lot more easier and
faster than a packed jar file.
On 8/9/06, Romain Quilici <r....@chem.usyd.edu.au> wrote:
> Hi all,
> I know that this question has been asked many times, but still something
> not clear for me.
> When an application is deployed as a war file, (as mentioned in the
> javadoc, or in several messages), context.getRealPath() will return null.
> However, Tomcat creates automatically a directory under webapps to
> contain war file contents, so I am wondering if Tomcat is using the
> newly generated directory to load the application(1st case) or
> the war file (2nd case).
> In the first case context.getRealPath("/") should return the path to the
> newly generated directory.
> In the second case, why does Tomcat generate the directory to contain
> war file contents?
> Thanks for the explanation
> Regards
> Romain
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
When we invent time, we invent death.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org