我是靠谱客的博主 慈祥丝袜,这篇文章主要介绍JSP获取路径与URL,现在分享给大家,希望可以做个参考。

<%@ 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);
%>
</body>
</html>

最后

以上就是慈祥丝袜最近收集整理的关于JSP获取路径与URL的全部内容,更多相关JSP获取路径与URL内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(135)

评论列表共有 0 条评论

立即
投稿
返回
顶部