You have to use getRealPath(String) method of ServletContext:

ex:

String virtual_path = "/something/somepage.txt";
ServletContext sc = getServletContext();
String physical_path = sc.getRalPath(virtual_path);

I hope will be helpfull!
F.

> -----Original Message-----
> From: Sun JunXu [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, January 12, 2000 8:55 AM
> To:   [EMAIL PROTECTED]
> Subject:      relative path in servlet
>
> hi, there,
> how to use a relative path in a servlet? ie. a file exists in
> /home/admin/file.txt, and on webserver, its virtual directory is
> 127.0.0.1/apps, in 127.0.0.1/appsclass/app.class, I want to get this file
> through relative path   ../apps/file.txt.
> File file=new File("../apps/file.txt");
>
> thanks a lot.
>
> sincerely
> sun
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to