I have taken this from jsp 2.0 spec please refer that
The <jsp:invoke> standard action can only be used in tag files (see
Chapter JSP.8, “Tag Files”), and must result in a translation error if used in a JSP.
It takes the name of an attribute that is a fragment, and invokes the fragment,
sending the output of the result to the JspWriter, or to a scoped attribute that can be
examined and manipulated. If the fragment identified by the given name is null,
<jsp:invoke> will behave as though a fragment was passed in that produces no
JSP.5.12.1 Basic Usage
The most basic usage of this standard action will invoke a fragment with the
given name with no parameters. The fragment will be invoked using the JspFragment.
invoke method, passing in null for the Writer parameter so that the results
will be sent to the JspWriter of the JspContext associated with the JspFragment.
The following is an example of such a basic fragment invocation:
JSP.5.12.2 Storing Fragment Output
It is also possible to invoke the fragment and send the results to a scoped
attribute for further examination and manipulation. This can be accomplished by
specifying the var or varReader attribute in the action. In this usage, the fragment
is invoked using the JspFragment.invoke method, but a custom java.io.Writer is
passed in instead of null.
If var is specified, the container must ensure that a java.lang.String object is
made available in a scoped attribute with the name specified by var. The String must contain the content sent by the fragment to the Writer provided in the Jsp-
If varReader is specified, the container must ensure that a java.io.Reader
object is constructed and is made available in a scoped attribute with the name
specified by varReader. The Reader object can then be passed to a custom action
for further processing. The Reader object must produce the content sent by the
1-120 STANDARD ACTIONS
JavaServer Pages 2.0 Specification
fragment to the provided Writer. The Reader must also be resettable. That is, if its
reset method is called, the result of the invoked fragment must be able to be read
again without re-executing the fragment.
An optional scope attribute indicates the scope of the resulting scoped
The following is an example of using var or varReader and the scope attribute:
<jsp:invoke fragment=”frag2” var=”resultString” scope=”session”/>
<jsp:invoke fragment=”frag3” varReader=”resultReader” scope=”page”/>