The Workshop is designed to help you review what you have learned and help you further increase your understanding of the material covered in this hour.
What are some of the effects of including a resource at compile time or run time?
What is jspf?
What class is used by servlets to include or forward to a resource?
If you want the client of a page to see the output of a resource that forwards to another, what can you do?
Resources that are included at compile time produce a compound resource that is used at runtime. The one becomes a part of the other. There may be a performance advantage since the runtime component is "prepared beforehand." Resources that are included at compile time cause the result of their evaluation at runtime to become a part of the output of the other. The most important effect of this is that the resources included at runtime are more limited—for example, they cannot set headers. However, this combination is often more flexible, since the included file can also be determine at runtime. Beyond simply selecting the resource at runtime, you can also mix servlets and JSPs.
jspf is an extension used with jsp segments, which are syntactically the same as a JSP, but are designed for inclusion as a type of component.
A RequestDispatcher is used for both operations. You use its include and forward methods.
Recall that forwarding to another resource causes the output buffer to be cleared. In most cases, this is desireable. If you want the client to see the output of the first page, flush the buffer prior to forwarding.
Write a JSP that includes another JSP at runtime. Pass a dynamic parameter such as the current time between the two. Display the parameter in the included page. Do this once using scriptlets or declarations and the other time without.
Repeat the previous exercise, substituting a servlet for the first JSP.