zoukankan      html  css  js  c++  java
  • JSP 08: page和pageContent内置对象

    1.  page内置对象, 等同于this

    在index.jsp中, 运行:

    <%
      System.out.println(page == this);
    %>

    效果:

    true

    2.  四大域对象:  page  request  session  appliaction

    page作用域:     在 当前JSP页面 有效

    request作用域:      在 请求/请求转发 里有效

    session作用域:   在 整个会话周期 有效 (在会话里的请求访问的都是同一个session)

    application作用域: 在 整个Web应用里 有效

    page < request < session < appliaction

    3.  pageContext

    pageContext.getOut();       // 得到了一个JSP Writter, 相当于得到了out对象

    pageContext.getRequest();     // 获取请求对象

    pageContext.getResponse();        // 获取response对象

    pageContext.getServletContext();   // 获取application 

    pageContext.getSession();      // 获取httpSession 

    pageContext.setAttribute("user","李诞");

    pageContext.setAttribute("user","庞博",PageContext.APPLICATION_SCOPE);  // 通过第三个变量, 设置了作用域

    例如, 在index.jsp中:

    <%
      pageContext.setAttribute("user","庞博",PageContext.SESSION_SCOPE);
      System.out.println(session.getAttribute("user"));
    %>

    效果:

      输出了庞博

  • 相关阅读:
    linux挂载
    kafka
    使用python27+flask
    arcpy 10.8计算最短路径,并复制出结果
    arcgis pro2.5使用试用
    arcgis engine create featureclass , gp工具
    python和c#的 opencv文字区域识别
    C#调用带参数并输出控制台的python的EXE程序
    arcgis10.8中 python27打包exe文件
    arcgis engine指定范围导出屏幕图片
  • 原文地址:https://www.cnblogs.com/JasperZhao/p/13505517.html
Copyright © 2011-2022 走看看