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

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

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

    筆記本

    JSP中與路徑相關(guān)的常用的幾個(gè)方法 轉(zhuǎn)

    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的請求路徑的相對于應(yīng)用程序的相對路徑

    request.getContextPath()返回應(yīng)用程序上下文相對路徑

    this.getRealPath(String str)返回UILstr對應(yīng)于本地磁盤的絕對路徑

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

    本文轉(zhuǎn)自:http://blog.pfan.cn/yiyi735/24718.html

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


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


    網(wǎng)站導(dǎo)航:
     
    <2009年2月>
    25262728293031
    1234567
    891011121314
    15161718192021
    22232425262728
    1234567

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(1)

    隨筆檔案

    ps

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲精品国产高清不卡在线| 精品国产精品久久一区免费式| 亚洲成av人片一区二区三区| 亚洲精品国产综合久久一线| 曰批免费视频播放在线看片二| 日韩免费视频观看| 亚洲欧美一区二区三区日产| 一个人免费观看www视频| 婷婷亚洲天堂影院| 一个人看的www在线免费视频| 亚洲毛片网址在线观看中文字幕 | 亚洲精品人成无码中文毛片 | 爱情岛亚洲论坛在线观看| 日本v片免费一区二区三区 | 亚洲av日韩专区在线观看| 免费a级毛片无码a∨性按摩| 黄色a三级三级三级免费看| 最近中文字幕2019高清免费| 亚洲视频一区在线| 扒开双腿猛进入爽爽免费视频| 色偷偷亚洲第一综合网| 久久亚洲高清综合| 91av免费观看| 亚洲欧美日韩中文高清www777| 无码欧精品亚洲日韩一区夜夜嗨 | 亚洲综合色自拍一区| 亚洲高清一区二区三区| 日本免费一区二区久久人人澡| 日韩精品视频免费网址| 国产成人无码免费看片软件| 亚洲日本在线观看| 日韩激情无码免费毛片| 成人毛片100免费观看| 亚洲高清无码综合性爱视频| 精品亚洲永久免费精品 | 免费又黄又爽又猛的毛片| 国产成年无码久久久免费| 亚洲一区二区视频在线观看| 久久大香伊焦在人线免费| 国产v亚洲v天堂a无| 免费看污成人午夜网站|