博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JSP page指令
阅读量:6403 次
发布时间:2019-06-23

本文共 12476 字,大约阅读时间需要 41 分钟。

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 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");%>
005index

Page指令

Page指令可以在页面内随便放置,最好放在页首;

language属性不写可以,写成别的会无法编译,异常为:org.apache.jasper.JasperException: /index005.jsp (line: 1, column: 2) Page directive: invalid language attribute

<%@ page import="a.b.*"%>

import属性,写了之后会自动添加到servlet的import语句中,但不进行包存在性的检查;反编译生成的class中就没有无效的包;

isThreadSafe问你的应用是否是线程安全的,缺省为true,表示应用是线程安全的,可以同时响应多个请求;如果设置为false,生成的servlet会实现javax.servlet.SingleThreadModel线程,那么一次只能处理一个用户请求;

${pageScope.pca }

isELIgnored忽略el表达式

errorPage="relativeURL" 设置处理异常事件的JSP文件。 isErrorPage="true | false" 设置此页是否为出错页,如果被设置为true,你就能使用exception对象.

extends="package.class" 标明JSP编译时需要加入的Java Class的全名,但是得慎重的使用它,它会限制JSP的编译能力.写成别的就无法转换了。org.apache.jasper.JasperException: Unable to compile class for JSP:

session="false"就没有session对象了;

contentType属性设置发送到客户端文档的响应报头的MIME类型和字符编码。多个使用;号分开。 pageEncodeing属性只用于更改字符编码。

buffer属性指定out对象(JspWriter)使用的缓冲区大小,以kb为单位,默认8kb。 none表示不使用缓冲区。这样要求设置报头或状态代码的jsp元素要出现在文件的顶部,任何HTML内容之前。 autoFlush属性控制当缓冲区满了后,是自动清空输出缓冲区(默认true),还是在缓冲区溢出后抛出异常(false)。 在buffer=none的时候,autoFlush=false是错误的。

定义一个可以在servlet中通过getServletInfo方法获取的字符串。 jsp容器做的是在servlet中生成getServletInfo方法返回info属性指定的String。

 

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
_jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.tomcat.InstanceManager _jsp_instancemanager; public java.util.Map
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("
\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("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("
\r\n"); out.write("
005index\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\t

Page指令

\r\n"); out.write("\t

Page指令可以在页面内随便放置,最好放在页首;

\r\n"); out.write("\t

language属性不写可以,写成别的会无法编译,异常为:org.apache.jasper.JasperException: /index005.jsp (line: 1, column: 2) Page directive: invalid language attribute

\r\n"); out.write("\t\r\n"); out.write("\t

import属性,写了之后会自动添加到servlet的import语句中,但不进行包存在性的检查;反编译生成的class中就没有无效的包;

\r\n"); out.write("\t

isThreadSafe问你的应用是否是线程安全的,缺省为true,表示应用是线程安全的,可以同时响应多个请求;如果设置为false,生成的servlet会实现javax.servlet.SingleThreadModel线程,那么一次只能处理一个用户请求;

\r\n"); out.write("\t

${pageScope.pca }

\r\n"); out.write("\t

isELIgnored忽略el表达式

\r\n"); out.write("\t

errorPage=\"relativeURL\" 设置处理异常事件的JSP文件。 isErrorPage=\"true | false\" 设置此页是否为出错页,如果被设置为true,你就能使用exception对象.

\r\n"); out.write("\t

extends=\"package.class\" 标明JSP编译时需要加入的Java Class的全名,但是得慎重的使用它,它会限制JSP的编译能力.写成别的就无法转换了。org.apache.jasper.JasperException: Unable to compile class for JSP:

\r\n"); out.write("\t

session=\"false\"就没有session对象了;

\r\n"); out.write("\t

contentType属性设置发送到客户端文档的响应报头的MIME类型和字符编码。多个使用;号分开。 pageEncodeing属性只用于更改字符编码。

\r\n"); out.write("\t

buffer属性指定out对象(JspWriter)使用的缓冲区大小,以kb为单位,默认8kb。 none表示不使用缓冲区。这样要求设置报头或状态代码的jsp元素要出现在文件的顶部,任何HTML内容之前。 autoFlush属性控制当缓冲区满了后,是自动清空输出缓冲区(默认true),还是在缓冲区溢出后抛出异常(false)。\r\n"); out.write("\t\t在buffer=none的时候,autoFlush=false是错误的。

\r\n"); out.write("\t

定义一个可以在servlet中通过getServletInfo方法获取的字符串。 jsp容器做的是在servlet中生成getServletInfo方法返回info属性指定的String。

\r\n"); out.write("\r\n"); out.write("\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
_jspx_dependants; private ExpressionFactory _el_expressionfactory; private InstanceManager _jsp_instancemanager; public String getServletInfo() { return "infotext"; } public Map
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("
\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("\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("
\r\n"); out.write("
005index\r\n"); out.write("\r\n"); out.write("\r\n"); out.write("\t

Page指令

\r\n"); out.write("\t

Page指令可以在页面内随便放置,最好放在页首;

\r\n"); out.write("\t

language属性不写可以,写成别的会无法编译,异常为:org.apache.jasper.JasperException: /index005.jsp (line: 1, column: 2) Page directive: invalid language attribute

\r\n"); out.write("\t\r\n"); out.write("\t

import属性,写了之后会自动添加到servlet的import语句中,但不进行包存在性的检查;反编译生成的class中就没有无效的包;

\r\n"); out.write("\t

isThreadSafe问你的应用是否是线程安全的,缺省为true,表示应用是线程安全的,可以同时响应多个请求;如果设置为false,生成的servlet会实现javax.servlet.SingleThreadModel线程,那么一次只能处理一个用户请求;

\r\n"); out.write("\t

${pageScope.pca }

\r\n"); out.write("\t

isELIgnored忽略el表达式

\r\n"); out.write("\t

errorPage=\"relativeURL\" 设置处理异常事件的JSP文件。 isErrorPage=\"true | false\" 设置此页是否为出错页,如果被设置为true,你就能使用exception对象.

\r\n"); out.write("\t

extends=\"package.class\" 标明JSP编译时需要加入的Java Class的全名,但是得慎重的使用它,它会限制JSP的编译能力.写成别的就无法转换了。org.apache.jasper.JasperException: Unable to compile class for JSP:

\r\n"); out.write("\t

session=\"false\"就没有session对象了;

\r\n"); out.write("\t

contentType属性设置发送到客户端文档的响应报头的MIME类型和字符编码。多个使用;号分开。 pageEncodeing属性只用于更改字符编码。

\r\n"); out.write("\t

buffer属性指定out对象(JspWriter)使用的缓冲区大小,以kb为单位,默认8kb。 none表示不使用缓冲区。这样要求设置报头或状态代码的jsp元素要出现在文件的顶部,任何HTML内容之前。 autoFlush属性控制当缓冲区满了后,是自动清空输出缓冲区(默认true),还是在缓冲区溢出后抛出异常(false)。\r\n"); out.write("\t\t在buffer=none的时候,autoFlush=false是错误的。

\r\n"); out.write("\t

定义一个可以在servlet中通过getServletInfo方法获取的字符串。 jsp容器做的是在servlet中生成getServletInfo方法返回info属性指定的String。

\r\n"); out.write("\r\n"); out.write("\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://gojea.baihongyu.com/

你可能感兴趣的文章
一起谈.NET技术,.Net Framework源代码中的模式之Prototype(原型模式)
查看>>
[shell 命令] find 查找文件
查看>>
windows下启动mysql服务的命令行启动和手动启动方法
查看>>
VTK三维点集轮廓凸包提取
查看>>
【概率论与数理统计】小结9-3 - 区间估计
查看>>
Golang性能调优入门
查看>>
sqlloader外部表
查看>>
golang笔记——数组与切片
查看>>
屏蔽可忽略的js脚本错误
查看>>
散文分享
查看>>
【Vue】vue.js常用指令
查看>>
NFS学习
查看>>
MySql常用命令总结
查看>>
又一年...
查看>>
文件上传框的美化+预览+ajax
查看>>
Linux VFS
查看>>
ext不能选中复制属性_如何实现Extjs的grid单元格只让选择(即可以复制单元格内容)但是不让修改?...
查看>>
python中print的作用*8、不能+8_在 Python 3.x 中语句 print(*[1,2,3]) 不能正确执行。 (1.0分)_学小易找答案...
查看>>
python 生成html代码_使用Python Markdown 生成 html
查看>>
axure如何导出原件_Axure 教程:轻松导出图标字体所有图标
查看>>