<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    筆記本

    JSP中與路徑相關的常用的幾個方法 轉

    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)返回UILstr對應于本地磁盤的絕對路徑

    request.getLocalAddr() 返回服務器IP地址

    本文轉自:http://blog.pfan.cn/yiyi735/24718.html

    posted on 2009-02-11 11:58 Robben仔 閱讀(571) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2009年2月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    1234567

    導航

    統計

    常用鏈接

    留言簿(1)

    隨筆檔案

    ps

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 少妇中文字幕乱码亚洲影视| 日本亚洲国产一区二区三区| 亚洲国产美女视频| 国产一区二区三区免费观看在线 | 成人啪精品视频免费网站| 4480yy私人影院亚洲| 99在线观看视频免费| 亚洲狠狠ady亚洲精品大秀| 18以下岁毛片在免费播放| 亚洲天堂一区二区三区| 毛片A级毛片免费播放| 亚洲 暴爽 AV人人爽日日碰| 女人18毛片水最多免费观看| 在线观看免费亚洲| 久久久久亚洲av成人无码电影| 一区二区视频在线免费观看| 亚洲日韩精品射精日| 无码人妻一区二区三区免费n鬼沢 无码人妻一区二区三区免费看 | 精品剧情v国产在免费线观看| 亚洲成a人片在线观看天堂无码| 又黄又爽无遮挡免费视频| 一级做a爰片久久毛片免费陪| 国产成人综合亚洲AV第一页| 无码人妻久久一区二区三区免费| 亚洲伊人久久大香线蕉| 在线免费观看国产视频| 久久免费国产精品| 亚洲婷婷在线视频| 国产免费69成人精品视频| 成人A毛片免费观看网站| 亚洲激情校园春色| 免费人妻无码不卡中文字幕18禁| 美女巨胸喷奶水视频www免费| 亚洲精品**中文毛片| 国产成人免费一区二区三区| 成人爽a毛片免费| 亚洲人成色777777精品| 亚洲女同成av人片在线观看| 国产va免费精品观看精品| 国产高清对白在线观看免费91| 亚洲电影在线免费观看|