Attributes page The relative URL of the page to be included. It must be an existing resource on the local Web server. flush The flush attribute determines whether the included resource has its buffer flushed before it is included. This attribute is required to have a Boolean value. With the JSP 1.0 and 1.1 specifications, "true" is the only legal attribute. This is due to the structure of the underlying Servlet specification. This is a required attribute.
With the JSP 1.1 specification an optional param attribute can specify request parameters to be sent to the resource:
The following example demonstrates including the previous date example in a new JSP page:
Example 3.6. include.jsp < TITLE>Using Comments Here I am including the page /core-jsp/date.jsp:
The output of this page is fairly simple (see Figure 3–1):
Figure 3-1. Output of include.jsp
What is interesting is the source of the page (see Figure 3–2). Notice that everything on the page was included, even the HTML open and close tags. It is also important to note that it was the output of the date.jsp page that was inserted into the page, not the source of the date.jsp page. The include action is "dumb" in the sense that is does not parse the contents of the page, but inserts them "as is." This means that the page was retrieved just as a normal client would. The JSP elements on date.jsp were processed before it was inserted into include.jsp.
Figure 3-2. View source of include.jsp
The forward action terminates the action of the current page and forwards the request to another resource, such as a static page, another JSP page, or a Java Servlet. A JSP page or a Servlet must be in the same context. Exactly what is forwarded is determined by the value of the page implicit object. The forward action is similar to the HTTP status code 302, where a server tells the browser to forward to a new URL. It is different in the fact that the URL specified must reside on the same server. It is also different in that the browser typically displays the same URL as the original request. In essence, a forward action receives a request, forwards it to the new URL, receives the response, and then returns it to the client. The client itself never has an indication that there was a forward action, or that the page requested received it's content from another resource. The forward action has only one parameter: page. Similar to the include action the value of the page attribute must be a relative URL on the same Web server.
Example 3.2. forward.jsp on the Server Using Comments
Again the same date.jsp is being used, although this time it is forwarded to by forward.jsp. The output of the page (Figure 3–3) looks almost exactly the same as Figure 3–1, noting that the URL listed is forward.jsp. The user has no idea that the page that was really retrieved was date.jsp.
Figure 3-3. Output of forward.jsp
Now take a look at the source of this page (see Figure 3–4).
Figure 3-4. View source of forward.jsp
The important thing to notice is that all of the data before and after the forward action was discarded. This means that the buffer for the actual forward.jsp was discarded. In the event that an original page is not buffered, and there was data sent to the browser, an exception would be raised. With the JSP 1.1 specification an optional param attribute can specify request parameters to be sent to the resource:
The plugin action is used to insert Java components into a JSP page. It determines the type of browser and inserts the