You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Gubler, Ruediger" <rg...@init-ka.de> on 2012/03/19 15:23:21 UTC
Access local path of servlet
Hello,
can I get the local webapps path in a servlet?
Yours Rüdiger
Re: Access local path of servlet
Posted by Jost Richstein <jr...@softdecc.com>.
servletContext.getRealPath("dummy.htm"), but make sure the content
is not being made available from a |.war| archive without unpacking it.
-------- Original-Nachricht --------
Betreff: Access local path of servlet
Von: Gubler, Ruediger <rg...@init-ka.de>
An: users@tomcat.apache.org <us...@tomcat.apache.org>
Datum: 19.03.2012 15:23
> Hello,
>
> can I get the local webapps path in a servlet?
>
>
> Yours Rüdiger
>
>
>
--
Jost Richstein
SoftDeCC Software GmbH
Email: jrichstein@softdecc.com
Tel.: +49 89 89 06 78 47
Fax.: +49 89 89 06 78 33
SoftDeCC Software GmbH; Gesellschaft mit beschränkter Haftung; Sitz der Gesellschaft: München; Registergericht: München, HRB 123667; Geschäftsführer: Ralf Malis, Georg Nüssel, Jost Richstein, Gerd Wilts
AW: AW: Access local path of servlet
Posted by "Gubler, Ruediger" <rg...@init-ka.de>.
Hi,
we must tell the 3rd-party software where are the files located it needs for the current request.
Yours Rüdiger
-----Ursprüngliche Nachricht-----
Von: Christopher Schultz [mailto:chris@christopherschultz.net]
Gesendet: Montag, 19. März 2012 17:06
An: Tomcat Users List
Betreff: Re: AW: Access local path of servlet
...
If you have direct access to the filesystem, why do you need to request the file from another piece of 3rd-party software?
...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: AW: Access local path of servlet
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ruediger,
On 3/19/12 10:39 AM, Gubler, Ruediger wrote:
> we are using a third party software which accesses files local on
> the server. We must send in our request the "local path" to this
> files (e.g. D:\myserver\webapps\data\thefiles\). My idea was to
> write a servelt which delivers me "D:\myserver\webapps" and the
> client application can add the rest of the path because this is a
> fixed part.
Beware.
$ wget
http://yourapp/get_file?path=../../Windows/System32/Config/Security.SAM
If you have direct access to the filesystem, why do you need to
request the file from another piece of 3rd-party software?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9nWV8ACgkQ9CaO5/Lv0PDl/gCbB3NeAu4SgCmglOmPbZpvGjg9
aXIAn2oS+u87bYdg4W3uJ08J+ecou171
=WQSZ
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
AW: Access local path of servlet
Posted by "Gubler, Ruediger" <rg...@init-ka.de>.
Hello,
we are using a third party software which accesses files local on the server.
We must send in our request the "local path" to this files (e.g. D:\myserver\webapps\data\thefiles\).
My idea was to write a servelt which delivers me "D:\myserver\webapps" and the client application can add the rest of the path because this is a fixed part.
Yours Rüdiger
-----Ursprüngliche Nachricht-----
Von: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Gesendet: Montag, 19. März 2012 15:31
An: Tomcat Users List
Betreff: RE: Access local path of servlet
> From: Gubler, Ruediger [mailto:rgubler@init-ka.de]
> Subject: Access local path of servlet
> can I get the local webapps path in a servlet?
Not sure what you mean by "local webapps path". If you mean the path in the local file system, you should be aware that the servlet spec is designed so that a servlet container can operate _without_ a local file system, so there's no guarantee of such a path existing.
If your goal is to access some resource located with your webapp, follow the procedure here:
http://wiki.apache.org/tomcat/HowTo#How_do_I_load_a_properties_file.3F
You should pretty much never use getRealPath(), since it may not be able to return anything useful.
- 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: Access local path of servlet
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Gubler, Ruediger [mailto:rgubler@init-ka.de]
> Subject: Access local path of servlet
> can I get the local webapps path in a servlet?
Not sure what you mean by "local webapps path". If you mean the path in the local file system, you should be aware that the servlet spec is designed so that a servlet container can operate _without_ a local file system, so there's no guarantee of such a path existing.
If your goal is to access some resource located with your webapp, follow the procedure here:
http://wiki.apache.org/tomcat/HowTo#How_do_I_load_a_properties_file.3F
You should pretty much never use getRealPath(), since it may not be able to return anything useful.
- 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