docs:programming:jsp:jsp_directives

JSP Directives

	<%@ 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

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>

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 />

This is used to define custom markup tags. Refer to JSP documentation for details on this.

  • docs/programming/jsp/jsp_directives.txt
  • Last modified: 2008/08/03 00:25
  • by 127.0.0.1