wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to get DISK absolute path according URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get DISK absolute path according URL " Watch "How to get DISK absolute path according URL " New topic
Author

How to get DISK absolute path according URL

liang sun
Ranch Hand

Joined: May 12, 2001
Posts: 51
How to get DISK absolute path according URL
Example: convert "http://sun:8080/a.jsp"
to "c:\aaa\a.jsp"
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
you can't unless you are inside that JSP page. Because you can map a context to anywhere on the disk you can't automatically know where it is. But if you are inside the JSP / Servlet you can use the context object and getRealPath to get the local path to the context.
[ November 09, 2003: Message edited by: Tim Baker ]

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

If I understand Tim's reply, that's not completely correct. You can use getRealPath() from anywhere inside a web app to find the path of a resource anywhere within the web application. You do not need to be within the resource itself.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get DISK absolute path according URL
 
Similar Threads
log4j error?
Create file object for each assets item.
genarate PDf and save it on server
absolute path Formfile upload
Relative URL specifications, JSP 1.2.1