• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get DISK absolute path according URL

 
liang sun
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to get DISK absolute path according URL
Example: convert "http://sun:8080/a.jsp"
to "c:\aaa\a.jsp"
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic