<%@ page contentType=;text/html; charset=gb; language=;java; import=;javaio*; errorPage=; %>
<html>
<head>
<meta httpequiv=;ContentType; content=;text/html; charset=gb;>
<title>Untitled Document</title>
</head>
<body>
當前WEB應用的物理路徑<%=applicationgetRealPath(;/;)%><BR>
當前你求請的JSP文件的物理路徑<%=applicationgetRealPath(requestgetRequestURI())%><BR>
<%
String path=applicationgetRealPath(requestgetRequestURI());
String dir=new File(path)getParent();
outprintln(;當前JSP文件所在目錄的物理路徑;+dir+;</br>;);
String realPath = ;http://; + requestgetServerName() + ;:; + requestgetServerPort() + requestgetContextPath()+requestgetServletPath()substring(requestgetServletPath()lastIndexOf(;/;)+);
outprintln(;web URL 路徑:;+realPath);
%>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/hx/201405/30811.html