| JSP Directives |
|
| The JSP page Directive |
| |
| The page directive lets us define one or more of the following case-sensitive attributes: |
| |
| . import="package.class" |
| or |
| import="package.class1,...,package.classN". |
| |
| This lets us specify what packages should be imported. |
| |
| For example: |
| <%@ page import="java.util.*" %> |
| The import attribute is the only one that is allowed to appear multiple times. |
| |
| . contentType="MIME-Type" |
| or |
contentType="MIME-Type;
charset=Character-Set" |
| This specifies the MIME type of the output. The default is text/html. |
| For example, the directive |
| <%@ page contentType="text/plain" %> |
| has the same effect as the scriptlet |
| <% response.setContentType("text/plain"); %> |
| |
| . isThreadSafe="true|false". |
| A value of true (the default) indicates normal servlet processing, where multiple requests can be processed simultaneously with a single servlet instance, under the assumption that the author synchronized access to instance variables. |
| A value of false indicates that the servlet should implement SingleThreadModel, with requests either delivered serially or with simultaneous requests being given separate servlet instances. |
| |
| . session="true|false". |
| A value of true (the default) indicates that the predefined variable session (of type HttpSession) should be bound to the existing session if one exists, otherwise a new session should be created and bound to it. |
| A value of false indicates that no sessions will be used, and attempts to access the variable session will result in errors at the time the JSP page is translated into a servlet. |
| |
| . buffer="sizekb|none". |
| This specifies the buffer size for the JspWriter out. The default is server-specific, but must be at least 8kb. |
| |
| . autoflush="true|false". |
| A value of true, the default, indicates that the buffer should be flushed when it is full. A value of false, rarely used, indicates that an exception should be thrown when the buffer overflows. A value of false is illegal when also using buffer="none". |
| |
| . extends="package.class". |
| This indicates the superclass of servlet that will be generated. Use this with extreme caution, since the server may be using a custom superclass already. |
| |
| . info="message". |
| This defines a string that can be retrieved via the getServletInfo method. |
| |
| . errorPage="url". |
| This specifies a JSP page that should process any Throwables thrown but not caught in the current page. |
| |
| . isErrorPage="true|false". |
| This indicates whether or not the current page can act as the error page for another JSP page. The default is false. |
| |
| . language="java". |
| At some point, this is intended to specify the underlying language being used. For now, don't bother with this since java is both the default and the only legal choice. |
| |
| The XML syntax for defining directives is |
| <jsp:directive.directiveType attribute=value /> |
| |
| For example, the XML equivalent of : |
| <%@ page import="java.util.*" %> |
| is |
| <jsp:directive.page import="java.util.*" /> |
|
| |
|
| |
| |