http:/localhost/123/jsp/test.jsp:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
<html:base />
<title>test.jsp</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<p>
<h2>application - javax.servlet.ServletContext</h2>
application.getRealPath("/")<%=application.getRealPath("/") %><br>
application.getMajorVersion() - <%=application.getMajorVersion() %><br>
application.getMimeType("txt") - <%=application.getMimeType("txt") %><br>
application.getServerInfo() - <%=application.getServerInfo() %><br>
application.getServletContextName() - <%=application.getServletContextName() %><br>
application.getContext()
</p>
<p>
<h2>config - javax.servlet.ServletConfig</h2>
config.getServletName() - <%=config.getServletName() %><br>
config.getServletContext()<br>
</p>
<p>
<h2>pageContext - javax.servlet.jsp.PageContext</h2>
pageContext.getRequest()(JSP中的requset隐式对象)<br>
pageContext.getResponse()(JSP中的response隐式对象)<br>
pageContext.getServletConfig()(JSP中的config隐式对象)<br>
pageContext.getServletContext()(JSP中的application隐式对象)<br>
pageContext.getException()(JSP中的exception隐式对象)<br>
pageContext.getSession()(JSP中的session隐式对象)<br>
pageContext.getOut()(JSP中的out隐式对象)
</p>
<p>
<h2>request - javax.servlet.http.HttpServletRequest</h2>
request.getLocalAddr() - <%=request.getLocalAddr() %><br>
request.getServletPath() - <%=request.getServletPath() %><br>
request.getContextPath() - <%=request.getContextPath() %><br>
request.getLocalName() - <%=request.getLocalName() %><br>
request.getLocalPort() - <%=request.getLocalPort() %><br>
request.getPathInfo() - <%=request.getPathInfo() %><br>
request.getProtocol() - <%=request.getProtocol() %><br>
request.getQueryString() - <%=request.getQueryString() %><br>
request.getRemoteAddr() - <%=request.getRemoteAddr() %><br>
request.getRemoteHost() - <%=request.getRemoteHost() %><br>
request.getRemotePort() - <%=request.getRemotePort() %><br>
request.getRemoteUser() - <%=request.getRemoteUser() %><br>
request.getRequestedSessionId():<%=request.getRequestedSessionId() %><br>
request.getRequestURI() - <%=request.getRequestURI() %><br>
request.getRequestURL() - <%=request.getRequestURL() %>
</p>
<p>
<h2>session - javax.servlet.http.HttpSession</h2>
session.getServletContext()
</p>
</body>
</html:html>
客户端显示如下:
application - javax.servlet.ServletContext
application.getRealPath("/")F:\workspace\tomcat\123\
application.getMajorVersion() - 2
application.getMimeType("txt") - null
application.getServerInfo() - Apache Tomcat/5.0.30
application.getServletContextName() - null
application.getContext()
config - javax.servlet.ServletConfig
config.getServletName() - jsp
config.getServletContext()
pageContext - javax.servlet.jsp.PageContext
pageContext.getRequest()
pageContext.getResponse()
pageContext.getServletConfig()
pageContext.getServletContext()
pageContext.getException()
pageContext.getSession()
pageContext.getOut()
request - javax.servlet.http.HttpServletRequest
request.getLocalAddr() - 127.0.0.1
request.getServletPath() - /jsp/test.jsp
request.getContextPath() - /123
request.getLocalName() - 127.0.0.1
request.getLocalPort() - 80
request.getPathInfo() - null
request.getProtocol() - HTTP/1.1
request.getQueryString() - null
request.getRemoteAddr() - 127.0.0.1
request.getRemoteHost() - 127.0.0.1
request.getRemotePort() - 1211
request.getRemoteUser() - null
request.getRequestedSessionId():5AFAE9C0A164621D4F8E0DAF2F253C92
request.getRequestURI() - /123/jsp/test.jsp
request.getRequestURL() - http://localhost/123/jsp/test.jsp
session - javax.servlet.http.HttpSession
session.getServletContext()
注:
http://localhost/123/taglib/html/result.jsp中使用以下方法
request.getServletPath() :返回request的请求路径的相对于应用程序的相对路径
request.getContextPath()返回应用程序上下文相对路径
this.getRealPath(String str)返回UIL中str对应于本地磁盘的绝对路径
request.getLocalAddr() 返回服务器IP地址
分享到:
相关推荐
JSP中java脚本获取绝对路径 。
获取文件夹路径,不是文件路径,但是这种方法需要设置安全等级,应为浏览器内核安全设置的时候是禁止范文文件夹路径的。
JSP中得到几种得到路径的方法,对此做出了总结。
java、servlet、jsp、class等等中如何获得所在的路径
可以获取文件完整路径,不过要求环境是在windows下的google浏览器,应为不同浏览器,不同操作系统下获取文件路径方法不同,我没有找到通用的方法,因为浏览器处于安全考虑本身就禁止访问本地中的文件系统。
jsp获取url路径的方法分析.docx
Jsp选择路径.rar Jsp选择路径.rar Jsp选择路径.rar Jsp选择路径.rar
JAVA类,JSP,Servlet获取工程路径.txt 总共罗列出了集中jsp servlet 在eclipse 里 获得项目工程路径的方法
本文实例讲述了jsp中获取当前目录的实现方法,分享给大家供大家参考。具体实现方法如下: 1、利用System.getProperty()函数获取当前路径: 代码如下:System.out.println(System.getProperty(“user.dir”));//user....
JSP中获得当前应用的相对路径和绝对路径 根目录所对应的绝对路径、 文件的绝对路径 、 当前web应用的绝对路径、 取得请求文件的上层目录……
根据PDF的存放路径,将PDF文件显示在JSP页面,可显示多个,也可显示固定的一个 根据具体需求在JSP页面显示一个或者多个PDF
本文实例讲述了jsp获取url路径的方法。分享给大家供大家参考,具体如下: 如果你请求的URL是 http://localhost:8080/demo/Index.jsp request.getScheme() //输出:http request.getServerName() //输出: ...
关于JSP/Servlet中的相对路径和绝对路径。2.1服务器端的地址服务器端的相对地址指的是相对于你的web应用的地址,这个地址是在服务器端解析的(不同于html和javascript中的相对地址,他们是由客户端浏览器解析的)
<a>/XXX.jsp”> //这样获得的是绝对路径 <a> //这样获得的是相对路径 <a>/XXXX.jsp”> 能够更有效的防治连接的失效。 request.getContextPath()得到的是项目的名字,如果项目为根目录,则得到一个””,即空的字条串...
[removed][removed] [removed][removed] account.jsp?name="+name+"&sex;="+sex; var name = $.query.get("name"); var sex = $.query.get("sex");
主要介绍了Java,JSP,Servlet获取当前工程路径(绝对路径)问题解析,需要的朋友可以参考下。
包括JSP编程中常用的js技术。 1.JSP编程中常用的js技术 2. 在下拉列表框里选择一个值后跳出新窗口? 3. 在JSP中启动execl? 4. 两级下拉列表框联动菜单? 5. java中如何把一个目录下的文件移到另一个指定的目录? 6. ...
jsp和sevlet中的相对路径和绝对路径!以及获取路径的方法!jsp 和 servlet的路径对比!文档很简单实用 !