Chinaunix首页 | 论坛 | 博客
  • 博客访问: 200859
  • 博文数量: 62
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 740
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-19 01:36
文章分类

全部博文(62)

文章存档

2009年(4)

2008年(58)

我的朋友

分类: 系统运维

2008-06-29 16:26:10

http:/localhost/123/jsp/test.jsp:
 
 
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="" prefix="bean" %>
<%@ taglib uri="" prefix="html" %>
<%@ taglib uri="" prefix="logic" %>
<%@ taglib uri="" prefix="tiles" %>
 
 
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
 <head>
    <html:base />
   
    <title>test.jsptitle>
 
    <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">
   
 
 head>
 
 <body>
<p>
    <h2>application - javax.servlet.ServletContexth2>
    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.ServletConfigh2>
    config.getServletName() - <%=config.getServletName() %><br>
    config.getServletContext()<br>
p>
 
<p>
    <h2>pageContext - javax.servlet.jsp.PageContexth2>
    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.HttpServletRequesth2>
    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.HttpSessionh2>
    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() -
session - javax.servlet.http.HttpSession
session.getServletContext()
注:
中使用以下方法
request.getServletPath() :返回request的请求路径的相对于应用程序的相对路径
request.getContextPath()返回应用程序上下文相对路径
this.getRealPath(String str)返回UIL中str对应于本地磁盘的绝对路径
request.getLocalAddr() 返回服务器IP地址
阅读(984) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~