zoukankan      html  css  js  c++  java
  • Jsp九大内置对象

     九大内置对象

    •   out(JspWriter):等同与response.getWriter(),用来向客户端发送文本数据;
    •   config(ServletConfig):对应“真身”中的ServletConfig
    •   page(当前JSP的真身类型):当前JSP页面的“this”,即当前对象;
    •   pageContext(PageContext):页面上下文对象,page域对象
    •   exception(Throwable):只有在错误页面中可以使用这个对象;
    •   request(HttpServletRequest):即HttpServletRequest类的对象;
    •   response(HttpServletResponse):即HttpServletResponse类的对象;
    •   application(ServletContext):即ServletContext类的对象;
    •   session(HttpSession):即HttpSession类的对象,

    不是每个JSP页面中都可以使用,如果在某个JSP页面中设置<%@page session=”false”%>,说明这个页面不能使用session。

    在这9个对象中有很多是极少会被使用的,例如:config、page、exception基本不会使用。

    在这9个对象中有两个对象不是每个JSP页面都可以使用的:exception、session。

    原理

    JSP页面的内容出现在“真身”的_jspService()方法中,而在_jspService()方法开头部分已经创建了9大内置对象。

    public void _jspService(HttpServletRequest request, HttpServletResponse response)
            throws java.io.IOException, ServletException {
    
        PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        JspWriter _jspx_out = null;
        PageContext _jspx_page_context = null;
    
    
        try {
          response.setContentType("text/html;charset=UTF-8");
          pageContext = _jspxFactory.getPageContext(this, request, response,
                      null, true, 8192, true);
          _jspx_page_context = pageContext;
          application = pageContext.getServletContext();
          config = pageContext.getServletConfig();
          session = pageContext.getSession();
          out = pageContext.getOut();
          _jspx_out = out;
       }…
    View Code
  • 相关阅读:
    韦大仙--Katalon---一款好用的selenium自动化测试插件
    Python之路,Day3
    Python之路,Day2
    Python之路,Day1
    Python基础02 基本数据类型
    Python基础01 Hello World!
    韦大仙--LoadRunner压力测试:详细操作流程
    韦大仙--python对文件操作 2--写入与修改
    韦大仙--python对文件操作
    更新pip10后 ImportError: cannot import name ‘main'
  • 原文地址:https://www.cnblogs.com/64Byte/p/12871586.html
Copyright © 2011-2022 走看看