JSP compilation Directives--------page compilation directives

Source: Internet
Author: User

First, JSP compilation instructions

A compile instruction is a message that notifies the JSP engine.

Its role is to set the properties of the JSP program and the servlet generated by the JSP. For example, specify the scripting language used by the JSP program, file encoding, and so on.

It does not generate output directly.

Compile directives have default values, and developers do not need to set values for each instruction.

There are three common compiler directives for JSP: page, include, Tablib

1. Page compilation Directives

Page compilation directives are primarily used to define the global properties of the current JSP program.

Includes the type of scripting language used by the current JSP program, the list of Java packages that need to be imported, and so on.

In general, page compilation directives are located at the top of the page. The same page can have multiple page compilation directives.

<%@ page language= "java" contenttype= "text/html; Charset=iso-8859-1 "pageencoding=" Iso-8859-1 "%>

Common Properties:

Language: Used to declare the type of scripting language used by the current JSP program. The default is "Java".

ContentType: Set the MIME (multi-purpose Internet Mail Extensions) type, set the encoding for the generated Web page

Pageencoding: Sets the encoding of the JSP program itself.

Import: For importing Java classes. If you do not import Java classes by using the Import property, you must use the fully qualified name (that is, the package name) when you use these classes in your script.

The following imports multiple Java classes through an import property.

Import= "Java.util.arraylist,java.util.linkedlist"

ErrorPage: Used to specify error handling pages. If the current JSP program produces an exception or an error, and the JSP program does not have a corresponding processing code, the JSP engine automatically invokes the JSP program specified by the directive.

Iserrorpage: Sets whether the current JSP program is an error handler.

<%@ page language= "java"  contenttype= "text/html;  Charset=utf-8 "    pageencoding=" UTF-8 "    errorpage=" handle_error.jsp "     %><! doctype html public  "-//w3c//dtd html 4.01 transitional//en"   "HTTP// Www.w3.org/TR/html4/loose.dtd ">
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "iserrorpage=" true "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >


JSP compilation Directives--------page compilation directives

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.