There are five different types of scripting elements
| Scripting Element | Example |
|---|---|
| Comment | <%-- comment --%> |
| Directive | <%@ directive %> |
| Declaration | <%! declarations %> |
| Scriptlet | <% scriplets %> |
| Expression | <%= expression %> |
Directive Tag gives special instruction to Web Container at the time of page translation. Directive tags are of three types: page, include and taglib.
| Directive | Description |
|---|---|
<%@ page ... %> |
defines page dependent properties such as language, session, errorPage etc. |
<%@ include ... %> |
defines file to be included. |
<%@ taglib ... %> |
declares tag library used in the page |
以下是page包含的属性
例如:
<%@ page import="java.util.Date" %>
or
<%@ page import="java.util.Date,java.net.*" %>
| 属性 | 描述 |
|---|---|
| buffer | 指定out对象使用缓冲区的大小 |
| autoFlush | 控制out对象的 缓存区 |
| contentType | 指定当前JSP页面的MIME类型和字符编码 |
| errorPage | 指定当JSP页面发生异常时需要转向的错误处理页面 |
| isErrorPage | 指定当前页面是否可以作为另一个JSP页面的错误处理页面 |
| extends | 指定servlet从哪一个类继承 |
| import | 导入要使用的Java类 |
| info | 定义JSP页面的描述信息 |
| isThreadSafe | 指定对JSP页面的访问是否为线程安全 |
| language | 定义JSP页面所用的脚本语言,默认是Java |
| session | 指定JSP页面是否使用session |
| isELIgnored | 指定是否执行EL表达式 |
| isScriptingEnabled | 确定脚本元素能否被使用 |