<%--
Document : test2
Created on : 2010-3-25, 8:17:15
Author : Administrator
--%>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.io.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
當前WEB應用的物理路徑:<%=application.getRealPath("/")%><BR>
當前你求請的JSP文件的物理路徑:<%=application.getRealPath(request.getRequestURI())%><BR>
<%
String path=application.getRealPath(request.getRequestURI());
String dir=new File(path).getParent();
out.println("當前JSP文件所在目錄的物理路徑"+dir+"</br>");
String realPath1 = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()+request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/")+1);
out.println("web URL 路徑:"+realPath1);
%>
<br>
<br>
<%
String path0 = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path0;
String uri = request.getRequestURI();
String q = request.getQueryString();
String url =basePath+uri+"?"+q ;
%>
<%=url %><br>
<%=basePath %><br>
<%
//String u = java.net.URLEncoder.encode("
String u = java.net.URLEncoder.encode("%>
<br>
<%=u%>
</body></html>
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請
點(diǎn)擊舉報。