Overview of JSP Syntax Element
 
Directives
 
Directives provide instruction to the JSP container regarding the entire JSP page. This information is used in translating or executing the page. The basic syntax is as follows:
<%@ directive attribute1="value1" attribute2="value2"... %>
 
The JSP specification supports the following directives:
 
page:
Use this directive to specify any of a number of page-dependent attributes, such as scripting language, content type and character encoding, a class to extend, packages to import, an error page to use, the JSP page output buffer size, and whether to automatically flush the buffer when it is full.
 
For example:
<%@ page language="java" import="packages.mypackage" errorPage="boof.jsp" %>
or, to enable auto-flush and set the JSP page output buffer size to 20 KB:
<%@ page autoFlush="true" buffer="20kb" %>
or, to unbuffer the page:
<%@ page buffer="none" %>
 
Its limitations:
1. The default buffer size is 8 KB.
2. It is illegal to set autoFlush="true" when buffer="none".
3. A JSP page using an error page must be buffered. Forwarding to an error page (not outputting it to the browser) clears the buffer.
4. In the Oracle JSP implementation, "java" is the default language setting. It is good programming practice to set it explicitly, however. You can also use a "sqlj" setting for SQLJ JSP pages.
5. For information about using page directive attributes to set the content type and character set for the JSP page and response object..
 
include:
Use this directive to specify a resource that contains text or code to be inserted into the JSP page when it is translated.
 
For example:
<%@ include file="/jsp/userinfopage.jsp" %>
 
Notes:
1. The include directive, referred to as a "static include", is comparable in nature to the jsp:include action discussed later in this chapter, but jsp:include takes effect at request-time instead of translation-time.
2. The include directive can be used only between files in the same servlet context (application).
 
taglib:
We use this directive to specify a library of custom JSP tags that will be used in the JSP page. Vendors can extend JSP functionality with their own sets of tags. This directive includes a pointer to a tag library descriptor file and a prefix to distinguish use of tags from that library.
 
For example:
<%@ taglib uri="/oracustomtags" prefix="oracust" %>