A JSP directive affects the overall structure of the servlet class. It usually has the following form:
<% @ directive attribute=”value” %>
There are 3 types of directives:
<% @page…%>-defines page dependent attributes,such as scripting language,error page and buffering reqquirements.
<%@include …%>-includes a file during translation of a page.
<%@taglib…%>-declares a tag library,containing custom actions used in the page.
JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically insert a file, reuse JavaBeans components, forward the user to another page, or generate HTML for the Java plugin.
There is only one syntax for the Action element, as it conforms to the XML standard:
It is possible to use “import” statements in JSPs, but the syntax is a little different from normal Java.
The first line in the above example is called a “directive”. A JSP “directive” starts with <%@ characters.
This one is a “page directive”. The page directive can contain the list of all imported packages. To import more than one item, separate the package names by commas, e.g.
<%@ page imports=”java.util.*.java.text.*” %>
There are a number of JSP directives, besides the page directive. Besides the page directives, the other most useful directives are include and taglib. We will be covering taglib separately.
The include directive is used to physically include the contents of another file. The included file can be HTML or JSP or anything else — the result is as if the original JSP file actually contained the included text. To see this directive in action, create a new JSP.
going to include hello.jsp…<br>
<%@ include file=”hello.jsp” %>