JSP中的9个内置对象

JSP提供了9个内置对象,在JSP页面中可以直接使用这九个对象。

 

内置对象:

 

对象名 说明
request javax.servlet.http.HttpServletRequest 客户端请求
response javax.servlet.http.HttpServletResponse 客户端响应
page java.lang.Object JSP页面
pageContext javax.servlet.jsp.PageContext 页面上下文,管理页面范围内的对象
session javax.servlet.http.HttpSession 管理session范围内的对象
application javax.servlet.ServletContext 管理应用范围内的对象
out javax.servlet.jsp.JspWriter 向客户端输出信息
config javax.servlet.ServletConfig 取得在web.xml中定义的初始化参数
exception java.lang.Throwable 异常

 

下面是对应的java代码:

 

public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
        throws java.io.IOException, javax.servlet.ServletException {

    final javax.servlet.jsp.PageContext pageContext;
    javax.servlet.http.HttpSession session = null;
    java.lang.Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);
    if (exception != null) {
      response.setStatus(javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    final javax.servlet.ServletContext application;
    final javax.servlet.ServletConfig config;
    javax.servlet.jsp.JspWriter out = null;
    final java.lang.Object page = this;
    javax.servlet.jsp.JspWriter _jspx_out = null;
    javax.servlet.jsp.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;

 

注意:exception对象只有在JSP页面中指定 <%@ page isErrorPage="true"%> 才会创建。

你可能感兴趣的:(jsp,内置对象)