• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

<jsp:invoke> for Tag files

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Q#19 (chapter#10) of HFSJ second edition, I couldn't find explaination about <jsp:invoke> and variable used as a directive in Tag file anywhere in the book.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't tell if there's one or not, but you can find an explanation in the JSP specification.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Following is the explanation -

I have taken this from jsp 2.0 spec please refer that

JSP.5.12 <jsp:invoke>
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
output.
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:invoke fragment=”frag1”/>
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-
Fragment.invoke call.
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
variable.
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”/>
 
namita sasa
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Rachana.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic