public void (HttpServletRequest request, HttpServletResponse response)
??????? throws java.io.IOException, ServletException {
??? JspFactory _jspxFactory = null;
??? 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 {
????? _jspxFactory = JspFactory.getDefaultFactory();
????? response.setContentType("text/html;charset=gb2312");
????? 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;
????? out.write("\r\n");
out.write("<html>\r\n");
????? out.write("?? <head>\r\n");
????? out.write("????? <title>登录成功</title>\r\n");
????? out.write("?? </head>\r\n");
????? out.write("?? <body>\r\n");
????? out.write("????? <h2>");
????? out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${sessionScope.userid}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
????? out.write("您好,欢迎登录网上书店!</h2>\r\n");
????? out.write("?? </body>\r\n");
????? out.write("</html>\r\n");
} catch (Throwable t) {
????? if (!(t instanceof SkipPageException)){
??????? out = _jspx_out;
??????? if (out != null && out.getBufferSize() != 0)
????????? out.clearBuffer();
??????? if (_jspx_page_context != null)
_jspx_page_context.handlePageException(t);
????? }
??? } finally {
????? if (_jspxFactory != null)
_jspxFactory.releasePageContext(_jspx_page_context);
??? }
}
}
从JSP被转换成的Java文件可以看出如下几点:
1) JSP文件中的内容基本都被包含在了_jspService方法中,实际上页面执行的过程就是这个方法执行的过程;
2) 页面中显示给用户的HTML信息都被转换成了out.println("XXXX")的形式;
3) 在_jspService方法中有两个参数request和response,
4) 在方法中生成了如下几个对象:
??? PageContext pageContext = null;
??? HttpSession session = null;
??? ServletContext application = null;
??? ServletConfig config = null;
??? JspWriter out = null;
??? Object page = this;
这就是传说中的内置对象(预定义对象)。
返回给客户端的代码(通过在客户端浏览器可以查看源文件):
<html>
?? <head>
????? <title>登录成功</title>
?? </head>
?? <body>
????? <h2>zhangsan您好,欢迎登录网上书店!</h2>
?? </body>
</html>
?
在此文件中看不到任何JSP的代码,而是纯HTML代码。与源文件不同的地方:
【1】源文件中的page指令没有了
【2】源文件中的${sessionScope.userid}没有了,而使用zhangsan代替了原来的表达式。
浏览器把这段HTML代码解析成界面显示给用户。
这就是从你编写的JSP文件到客户端看到的结果的转换过程。
?