Previous | Next |
<%@ directive attribute="value" %> <%@ directive attr1="value" attr2="value" ... attrN="value" %>
Directives are used to specify the structure of the resulting servlet. There are three directives: page, include, and taglib
1. The page Directive
There are 11 specifiable attributes for this directive: import, contentType, isThreadSafe, session, buffer, autoflush, extends, info, errorPage, and language
Example
<%@ page language="java" contentType="text/html" %> <%@ page contentType="application/vnd.ms-excel" %> <%@ page import="java.util.*" %> <%@ page import="java.util.*,java.io.*" %>
Directives can be placed anywhere in the document, but are often placed at the very top.
<%@ page language="java" contentType="text/html import="java.util.*" %> <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <H1>Hello World</H1> Today is: <%= new Date().toString() %> </BODY> </HTML>
2. The include Directive
Is used to include a file in the main document.
There are two versions of this. The first one, shown below, includes the file at translation time.
<%@ include file="relative URL of file" %>
The second version, includes the file at request time.
<jsp:include page="ralative URL of file" flush=true />
3. The taglib directive
This is used to define custom markup tags. Refer to JSP documentation
for details on this.
Previous | Next |
Created by Deepak Kumar (dkumar@acm.org)