JSP: Include include the output of other pages (Dynamic inclusion) during the North request of the Home Page)
The include command is different from the previous one. JSP code is inserted (static inclusion) before the main page is converted to servlet)
JSP: plugin for Applet
The most stupid way is to use the copy and post method when multiple pages share a part, and then use the inclusion mechanism provided by different servers. It is best to use the above three portable methods.
Page JSP: Include during request
1,Can contain this content: HTML page content, plain text document content, JSP page output, Servlet output. = Include method of requestdispatcher.
2,Syntax: <JSP: Include page = "relative-path-to-resource"/> the path here can be relative to the home page path (/), relative to the application's root directory (Add/), to prevent illegal access to the client, it is best to put the contained page in the WEB-INF directory. The flush attribute can be added to specify whether to clear the output stream of the home page before the page is included (false by default ).
3,Add Request Parameters: The request object that can be included on the page is shared with the home page. However, you can configure some parameters for the North contained page on the home page. The syntax is as follows:
<JSP: Include page = "/framents/standardheading. jsp">
<JSP: Param name = "bgcolor" value = "yellow"/>
</Jsp: Include>
If the new parameter and the client submit parameter have the same name, the new parameter is used first.
Include files during page conversion: include command two JSP page inclusion Mode Comparison
|
JSP: include action |
Include command |
Time when an action is included |
Request Period |
Page conversion period
|
Included content |
Page output |
Actual File Content |
How many servlets are generated? |
Two (both the home page and North contained page have independent servlets) |
One (the North include file is first inserted into the home page, and then the obtained page is converted to servlet in the North) |
Whether the contained page can set the response header of the Home Page |
No |
Yes |
Whether the contained page can define the fields or methods on the home page |
No |
Yes |
Whether to update the home page when the included page is changed |
No |
Yes |
Equivalent servlet code |
Requestdispatcher's include Method |
No |
The related specifications only require that the homepage be changed and updated dynamically. Therefore, the include command method must be manually touch (on Linux) on the home page or on the home page, maintain a comment indicating the Update Time to explicitly update the server. The JSP: Include method automatically detects and updates the servlet compiled by JSP.
Of course, the includ command <% include file = "...... "%> XML Compatibility Statement: <JSP: Directive. Include File = "...... "/>.
The effect of Using JSP: forward to forward requests is the same as that of using the Servlet's requestdispatcher's forward method. However, we recommend that you store this logic in servlet.