Basic knowledge of JSP Syntax (ii)

Source: Internet
Author: User

1. Instruction <%@%>

(1) Page directive

 defining properties for an entire page by setting multiple properties inside
 Syntax: <%@ page Property 1 = "Property Value" Property 2 = "Property value 1, property value 2" ... Property N= "Property value N"%>

Page directive Common Properties:


Example: <%@ page language= "java" contenttype= "TEXT/HTML;CHARSET=GBK"%>


(2) include directive

The  contains actions that can be included in some duplicate code to continue to be used. This type of inclusion is called "Static containment."
 syntax: <% @include file= "file path to include"%>
For example:
<%@ include file=include1.jsp "%>
<jsp:include/>


2.JSP Standard Action

(1) <jsp:include/>

 can include other files, which are included in the dynamic inclusion
 Syntax:
 parameter not passed: <jsp:include page= "{file path to include}"/>
 Passing parameters
<jsp:include page= "{file path to include}" >
<jsp:param name = "parameter name 1" value = "parameter content 1"/>
<jsp:param name = "Parameter Name 2" VALUE = "parameter Content 2"/>
... Multiple parameters can be passed to the contained page
</jsp:include>


(2) Static inclusion differs from dynamic inclusion

 static includes:

include1.jsp page

<span style= "FONT-SIZE:18PX;" ><%int x =;%>

include2.jsp page

<span style= "FONT-SIZE:18PX;" ><%@ page contenttype= "text/html" pageencoding= "GBK"%>
when the program runs with 500 HTTP status code, which is a server error, X is repeatedly defined. While observing the JSP
Engine compiled Java file: Only one Java file has been generated. Therefore, the static contains the first containing the following
The form of the rationale.

 Dynamic includes:

<span style= "FONT-SIZE:18PX;" ><%@ page contenttype= "text/html" pageencoding= "GBK"%>
The program runs without errors, dynamically including if it contains a dynamic page, with the first processing after the inclusion form.

3. <jsp:forward/>

 from the current page to the specified page, jump operation belongs to the server-side jump, the page path after the jump is not
Change
 Syntax:
 parameters are not passed
<jsp:forward page = "file path to include" >
 Passing parameters
<jsp:forward page = "file path to include" >
<jsp:param name = "parameter name" VALUE = "parameter Contents"/>
... Multiple parameters can be passed to the contained page
</jsp:forward>
For example:
Forward2.jsp for post-jump pages

<span style= "FONT-SIZE:18PX;" ><%@ page contenttype= "text/html" pageencoding= "GBK"%>

forward1.jsp the page where the jump occurred

<pre name= "code" class= "HTML" ><span style= "font-size:18px;" >















Basic knowledge of JSP Syntax (ii)

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.