JSP Note 2 (compilation instructions and action instructions)

Source: Internet
Author: User

First, the JSP compiler instruction is to inform the JSP engine the message, does not produce the output.

3 compiler directives for JSP:

Page: Instructions for the current page
Include: An instruction that contains another page
Taglib: Used to define and access custom labels

Compile instruction format:
<%@ compiler directive Name property = "attribute value" ...%>

the meaning of each property of the page directive:
1.language: Declares the type of scripting language used by the current page, because the page is a JSP page, so the property value is usually Java, and the default is Java

2.extends: Specifies the parent class inherited by the Java class that is generated by the JSP compilation or the implemented connection

3.import: Import the package. The default imported packages have java.lang.*,java.servlet.*,java.servlet.jsp.*,javax.servlet.http.*, which do not need to display the import

4.session: Set whether the JSP page needs to open the HTTP session

5.buffer: Sets the size of the output buffer. Default is 8KB, can be set to none, or set to a different value, in kilobytes

6.autoFlush: If the output buffer is about to overflow, the content of the output buffer needs to be forced. Set to True for normal output, set to False to produce an exception when buffer overflows

7.info: Sets the information or description for the JSP. Available Servlet.getservletinfo () to obtain. You can use Getservletinfo () directly in the JSP page to get

8.errorPage: Specifies the error handling page. If this page produces an exception or an error, and no corresponding code program is processed, the JSP page specified by the property is automatically invoked

9.isError: Set this page as error handling page

 10.contentType: Specifies the file format and encoding character set for the generated Web page, which is the MIME type and page character set type, the default MIME type is text/html; The default character set type is Iso-8859-1

 11:pageencoding: Specifies the coded character set of the generated Web page


 Include directive:
<%@ include file= "test.jsp"%>

Second, the JSP's action instruction, and the compiler instruction is different, the compilation instruction is notifies the Servlet engine processing message, when compiles the JSP to the servlet the function, but the action instruction usually can replace the JSP script

  7 Action commands for JSP:
   1.jsp:forward: page forwarding, no loss of request parameters, the URL of the page address bar will not change

<page= "test.jsp"><name= "Age"  value= "/>"</jsp:forward>  

By forwarding this page to the Test.jsp page and carrying the age parameter, you can use Request.getparameter ("age") in the Test.jsp page to receive the parameter

2.jsp:param: Pass parameters, must be used with other tags

3.jsp:include: Dynamically introduces a JSP page that can carry parameters

<page= "test2.jsp"><name= "Age"  value= "/>"</jsp:include>  

This page introduces the test2.jsp page, which simply inserts the contents of the test2.jsp body into this page

4.jsp:userbean: Creating an JavaBean instance

<id= "Person"  class= "Com.edu.hue.Person"  scope= "Page"/>

5.jsp:setproperty: Setting properties of an JavaBean instance

<name=  ' person ' property= ' age '  value = "+" />

6.jsp:getproperty: Output The properties of an JavaBean instance

<name=  ' person ' property= ' age '/>

7.jsp:plugin: Used to download JavaBean or applets to client execution

JSP Note 2 (compilation instructions and action instructions)

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.