Jsp note 2 (compilation instructions and action instructions), jsp Compilation

Source: Internet
Author: User

Jsp note 2 (compilation instructions and action instructions), jsp Compilation

1. jsp compilation commands notify the jsp Engine of messages and do not generate output.

Three jsp compilation commands:

Page: commands for the current page
Include: commands that contain another page
Taglib: used to define and access custom tags

Compilation instruction format:
<% @ Compile command name attribute = "property value"... %>

Meaning of each attribute of the page command:
1. language: Declares the type of script language used on the current page. Because the page is a jsp page, the attribute value is usually java, and the default value is java.

2. extends: Specifies the parent class inherited by the java class generated by jsp compilation or the Implemented interfaces.

3. import: import the package. By default, the imported packages include java. lang. *, java. servlet. *, java. servlet. jsp. *, and javax. servlet. http. *.

4. session: Set whether to enable HTTP Session for this jsp page

5. buffer: set the size of the output buffer. The default value is 8 kb. It can be set to none or another value, in kb.

6. autoFlush: whether to force the output buffer content when the output buffer is about to overflow. If it is set to true, the output is normal. If it is set to false, an exception occurs during buffer Overflow.

7. info: Set the jsp information or description. It can be obtained using Servlet. getServletInfo. You can use getServletInfo () to obtain the information on the jsp page.

8. errorPage: Specifies the error handling page. If an exception or error occurs on this page and no corresponding code program is used for processing, the jsp page specified by this attribute is automatically called.

9. isError: Set whether this page is an error handling page

10. contentType: Specifies the file format and encoding character set for the page to be generated, that is, the MIME type and the page character set type, the default MIME type is text/html; the default character set type is ISO-8859-1

11: pageEncoding: Specifies the encoding Character Set of the generated webpage.


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

 

Ii. jsp action commands, unlike the compilation commands, are used to notify the Servlet engine to process messages and take effect when jsp is compiled into a Servlet. Action commands can usually be replaced with jsp scripts.

  Seven action commands of jsp:
1. jsp: forward: Page forwarding. Request Parameters are not lost, And the url in the page address bar is not changed.

<jsp:forward page="test.jsp">  <jsp:param name="age" value="18"/></jsp:forward>

This page is forwarded to the test. jsp page with age parameters. You can use request. getParameter ("age") on the test. jsp page to receive parameters.

2. jsp: param: Passing parameters, which must be used with other labels

3. jsp: include: dynamically introduces a jsp page with Parameters

<jsp:include page="test2.jsp">  <jsp:param name="age" value="18"/></jsp:include>

This page introduces the test2.jsp page. Here, the content of the body of test2.jsp is inserted into this page.

4. jsp: userBean: Create a JavaBean instance

<jsp:userBean id="person" class="com.edu.hue.Person" scope="page"/>

5. jsp: setProperty: Set attributes of the JavaBean instance

<jsp:setProperty name="person" property="age" value="18"/>

6. jsp: getProperty: outputs the attributes of the JavaBean instance.

<jsp:getProperty name="person" property="age"/>

7. jsp: plugin: used to download JavaBean or Applet to the client for execution

 

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.