44-描述JSP的9大内置对象(不重要)

首先,对于我们现在来说,用JSP的内置对象来直接开发的基本没有了,除非是比较老旧的项目,jsp的内置对象,则是不需要在jsp页面中创建,直接可以使用。

其实,我们通过观察jsp生成的java文件可以发现,其背后是帮我们创建了这些对象,所以对象的创建方式还是没有改变的。

我们去观察背后生成java类,那么里面是有给各个对象创建及初始化的代码(截取部分代码片段)

1
2
3
4
5
6
7
8
9
10
11
12
13
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)


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;

....

来,如果面试官问到这个问题,记得多少回答多少即可。

内置对象名 类型
request (HttpServletRequest)
response (HttpServletResponse)
config (ServletConfig)
application (ServletContext)
session (HttpSession)
exception (Throwable)
page (Object(this))
out (JspWriter)
pageContext (PageContext)