Question

I came across a post which says that, <jsp:forward> or <jsp:include> actions in a JSP, needs buffering to be enabled. Can anyone please tell me why is that?

Was it helpful?

Solution

The JSP that contains the <jsp:forward> action stops processing, clears its buffer, and forwards the request to the target resource. Note that the calling JSP should not write anything to the response prior to the action

The include action, on the other hand, executes for each client request of the JSP, which means the file is not parsed but included in place. This provides the capability to dynamically change not only the content that you want to include, but also the output of that content. The syntax for the include action is <jsp:include page="some-filename" flush="true" />. Note that the flush attribute must always be included (in JSP 1.1) to force a flush of the buffer in the output stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top