标签:
JSP page指令:
JSP文件:
<%@ page language="java"%> <%@ page import="java.util.*"%> <%@ page isThreadSafe="false"%> <%@ page contentType="text/html; charset=UTF-8"%> <%@ page isELIgnored="true"%> <%@ page isErrorPage="true"%> <%@ page errorPage="index0051.jsp"%> <!-- %@ page extends="org.apache.jsp"% --> <%@ page session="false"%> <%@ page buffer="none"%> <%@ page autoFlush="true"%> <%@ page info="infotext"%> <%@ page pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; pageContext.setAttribute("pca", "pageContextAttribute"); //session.setAttribute("s", "session"); %> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>005index</title> </head> <body> <p>Page指令</p> <p>Page指令可以在页面内随便放置,最好放在页首;</p> <p>language属性不写可以,写成别的会无法编译,异常为:org.apache.jasper.JasperException: /index005.jsp (line: 1, column: 2) Page directive: invalid language attribute</p> <%@ page import="a.b.*"%> <p>import属性,写了之后会自动添加到servlet的import语句中,但不进行包存在性的检查;反编译生成的class中就没有无效的包;</p> <p>isThreadSafe问你的应用是否是线程安全的,缺省为true,表示应用是线程安全的,可以同时响应多个请求;如果设置为false,生成的servlet会实现javax.servlet.SingleThreadModel线程,那么一次只能处理一个用户请求;</p> <p>${pageScope.pca }</p> <p>isELIgnored忽略el表达式</p> <p>errorPage="relativeURL" 设置处理异常事件的JSP文件。 isErrorPage="true | false" 设置此页是否为出错页,如果被设置为true,你就能使用exception对象.</p> <p>extends="package.class" 标明JSP编译时需要加入的Java Class的全名,但是得慎重的使用它,它会限制JSP的编译能力.写成别的就无法转换了。org.apache.jasper.JasperException: Unable to compile class for JSP:</p> <p>session="false"就没有session对象了;</p> <p>contentType属性设置发送到客户端文档的响应报头的MIME类型和字符编码。多个使用;号分开。 pageEncodeing属性只用于更改字符编码。</p> <p>buffer属性指定out对象(JspWriter)使用的缓冲区大小,以kb为单位,默认8kb。 none表示不使用缓冲区。这样要求设置报头或状态代码的jsp元素要出现在文件的顶部,任何HTML内容之前。 autoFlush属性控制当缓冲区满了后,是自动清空输出缓冲区(默认true),还是在缓冲区溢出后抛出异常(false)。 在buffer=none的时候,autoFlush=false是错误的。</p> <p>定义一个可以在servlet中通过getServletInfo方法获取的字符串。 jsp容器做的是在servlet中生成getServletInfo方法返回info属性指定的String。</p> </body> </html>
JSP转换的java文件:
/* * Generated by the Jasper component of Apache Tomcat * Version: Apache Tomcat/7.0.35 * Generated at: 2015-10-20 00:27:17 UTC * Note: The last modified time of this file was set to * the last modified time of the source file after * generation to assist with modification tracking. */ package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import java.util.*; import a.b.*; public final class index005_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent, javax.servlet.SingleThreadModel { public java.lang.String getServletInfo() { return "infotext"; } private static final javax.servlet.jsp.JspFactory _jspxFactory = javax.servlet.jsp.JspFactory.getDefaultFactory(); private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map<java.lang.String,java.lang.Long> getDependants() { return _jspx_dependants; } public void _jspInit() { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig()); } public void _jspDestroy() { } 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; 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, "index0051.jsp", false, 0, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("<!-- %@ page extends=\"org.apache.jsp\"% -->\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; pageContext.setAttribute("pca", "pageContextAttribute"); //session.setAttribute("s", "session"); out.write("\r\n"); out.write("<!DOCTYPE html>\r\n"); out.write("<html>\r\n"); out.write("<head>\r\n"); out.write("<meta charset=\"UTF-8\">\r\n"); out.write("<title>005index</title>\r\n"); out.write("</head>\r\n"); out.write("<body>\r\n"); out.write("\t<p>Page指令</p>\r\n"); out.write("\t<p>Page指令可以在页面内随便放置,最好放在页首;</p>\r\n"); out.write("\t<p>language属性不写可以,写成别的会无法编译,异常为:org.apache.jasper.JasperException: /index005.jsp (line: 1, column: 2) Page directive: invalid language attribute</p>\r\n"); out.write("\t\r\n"); out.write("\t<p>import属性,写了之后会自动添加到servlet的import语句中,但不进行包存在性的检查;反编译生成的class中就没有无效的包;</p>\r\n"); out.write("\t<p>isThreadSafe问你的应用是否是线程安全的,缺省为true,表示应用是线程安全的,可以同时响应多个请求;如果设置为false,生成的servlet会实现javax.servlet.SingleThreadModel线程,那么一次只能处理一个用户请求;</p>\r\n"); out.write("\t<p>${pageScope.pca }</p>\r\n"); out.write("\t<p>isELIgnored忽略el表达式</p>\r\n"); out.write("\t<p>errorPage=\"relativeURL\" 设置处理异常事件的JSP文件。 isErrorPage=\"true | false\" 设置此页是否为出错页,如果被设置为true,你就能使用exception对象.</p>\r\n"); out.write("\t<p>extends=\"package.class\" 标明JSP编译时需要加入的Java Class的全名,但是得慎重的使用它,它会限制JSP的编译能力.写成别的就无法转换了。org.apache.jasper.JasperException: Unable to compile class for JSP:</p>\r\n"); out.write("\t<p>session=\"false\"就没有session对象了;</p>\r\n"); out.write("\t<p>contentType属性设置发送到客户端文档的响应报头的MIME类型和字符编码。多个使用;号分开。 pageEncodeing属性只用于更改字符编码。</p>\r\n"); out.write("\t<p>buffer属性指定out对象(JspWriter)使用的缓冲区大小,以kb为单位,默认8kb。 none表示不使用缓冲区。这样要求设置报头或状态代码的jsp元素要出现在文件的顶部,任何HTML内容之前。 autoFlush属性控制当缓冲区满了后,是自动清空输出缓冲区(默认true),还是在缓冲区溢出后抛出异常(false)。\r\n"); out.write("\t\t在buffer=none的时候,autoFlush=false是错误的。</p>\r\n"); out.write("\t<p>定义一个可以在servlet中通过getServletInfo方法获取的字符串。 jsp容器做的是在servlet中生成getServletInfo方法返回info属性指定的String。</p>\r\n"); out.write("</body>\r\n"); out.write("</html>\r\n"); } catch (java.lang.Throwable t) { if (!(t instanceof javax.servlet.jsp.SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } }
反编译class文件:
package org.apache.jsp; import java.io.IOException; import java.util.Map; import javax.el.ExpressionFactory; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.SingleThreadModel; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.JspApplicationContext; import javax.servlet.jsp.JspFactory; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.SkipPageException; import org.apache.jasper.runtime.HttpJspBase; import org.apache.jasper.runtime.InstanceManagerFactory; import org.apache.jasper.runtime.JspRuntimeLibrary; import org.apache.jasper.runtime.JspSourceDependent; import org.apache.tomcat.InstanceManager; public final class index005_jsp extends HttpJspBase implements JspSourceDependent, SingleThreadModel { private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory(); private static Map<String, Long> _jspx_dependants; private ExpressionFactory _el_expressionfactory; private InstanceManager _jsp_instancemanager; public String getServletInfo() { return "infotext"; } public Map<String, Long> getDependants() { return _jspx_dependants; } public void _jspInit() { this._el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); this._jsp_instancemanager = InstanceManagerFactory.getInstanceManager(getServletConfig()); } public void _jspDestroy() { } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Throwable exception = JspRuntimeLibrary.getThrowable(request); if (exception != null) { response.setStatus(500); } JspWriter out = null; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=UTF-8"); PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "index0051.jsp", false, 0, true); _jspx_page_context = pageContext; pageContext.getServletContext(); pageContext.getServletConfig(); out = pageContext.getOut(); _jspx_out = out; out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("<!-- %@ page extends=\"org.apache.jsp\"% -->\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\r\n"); String path = request.getContextPath(); new StringBuilder(String.valueOf(request.getScheme())).append("://").append(request.getServerName()).append(":").append(request.getServerPort()).append(path).append("/").toString(); pageContext.setAttribute("pca", "pageContextAttribute"); out.write("\r\n"); out.write("<!DOCTYPE html>\r\n"); out.write("<html>\r\n"); out.write("<head>\r\n"); out.write("<meta charset=\"UTF-8\">\r\n"); out.write("<title>005index</title>\r\n"); out.write("</head>\r\n"); out.write("<body>\r\n"); out.write("\t<p>Page指令</p>\r\n"); out.write("\t<p>Page指令可以在页面内随便放置,最好放在页首;</p>\r\n"); out.write("\t<p>language属性不写可以,写成别的会无法编译,异常为:org.apache.jasper.JasperException: /index005.jsp (line: 1, column: 2) Page directive: invalid language attribute</p>\r\n"); out.write("\t\r\n"); out.write("\t<p>import属性,写了之后会自动添加到servlet的import语句中,但不进行包存在性的检查;反编译生成的class中就没有无效的包;</p>\r\n"); out.write("\t<p>isThreadSafe问你的应用是否是线程安全的,缺省为true,表示应用是线程安全的,可以同时响应多个请求;如果设置为false,生成的servlet会实现javax.servlet.SingleThreadModel线程,那么一次只能处理一个用户请求;</p>\r\n"); out.write("\t<p>${pageScope.pca }</p>\r\n"); out.write("\t<p>isELIgnored忽略el表达式</p>\r\n"); out.write("\t<p>errorPage=\"relativeURL\" 设置处理异常事件的JSP文件。 isErrorPage=\"true | false\" 设置此页是否为出错页,如果被设置为true,你就能使用exception对象.</p>\r\n"); out.write("\t<p>extends=\"package.class\" 标明JSP编译时需要加入的Java Class的全名,但是得慎重的使用它,它会限制JSP的编译能力.写成别的就无法转换了。org.apache.jasper.JasperException: Unable to compile class for JSP:</p>\r\n"); out.write("\t<p>session=\"false\"就没有session对象了;</p>\r\n"); out.write("\t<p>contentType属性设置发送到客户端文档的响应报头的MIME类型和字符编码。多个使用;号分开。 pageEncodeing属性只用于更改字符编码。</p>\r\n"); out.write("\t<p>buffer属性指定out对象(JspWriter)使用的缓冲区大小,以kb为单位,默认8kb。 none表示不使用缓冲区。这样要求设置报头或状态代码的jsp元素要出现在文件的顶部,任何HTML内容之前。 autoFlush属性控制当缓冲区满了后,是自动清空输出缓冲区(默认true),还是在缓冲区溢出后抛出异常(false)。\r\n"); out.write("\t\t在buffer=none的时候,autoFlush=false是错误的。</p>\r\n"); out.write("\t<p>定义一个可以在servlet中通过getServletInfo方法获取的字符串。 jsp容器做的是在servlet中生成getServletInfo方法返回info属性指定的String。</p>\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)) try { out.clearBuffer(); } catch (IOException localIOException) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } _jspxFactory.releasePageContext(_jspx_page_context); } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } }
标签:
原文地址:http://www.cnblogs.com/stono/p/4893624.html