Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between <jsp:invoke> and <jsp:doBody> actions

 
Johnnie Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I want to know the difference between <jsp:invoke> and <jsp:doBody> actions in JSP 2.0. According to the specification, both perform the same task of invoking the body of a tag. But <jsp:doBody> operates on the body of the tag instead of on a specific fragment passed as an attribute.

I have used <jsp:doBody> successfully but I have not yet managed to understand the meaning of "specific fragment passed as an attribute".

Can somebody elaborate more on the use of <jsp:invoke> and explain the difference between the 2 actions, perhaps with the help of a small example?

Thanks & Regards,
John.
 
Amrit pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To understand the difference between <jsp:invoke> and <jsp:doBody> , we must first understand what is fragment:

============================================================================================================================================
JSP Fragment :

JSP Fragments is a new feature of JSP 2.0 that allows page authors to create custom action fragments that can be invoked. It allows a portion of JSP code to be encapsulated into a Java object that can be passed around and evaluated zero or more times. Template text and expression evaluations can be included in JSP fragments.

============================================================================================================================================

There can be more than one fragment for a JSP page. If we notice carefully, we will find that invoke has a required attribute called "fragment", whereas doBody has not.

Hence , <jsp:doBody> operates only on the body of the tag instead of a specific fragment (as it does not have "fragment" attribute to operate on a particular fragment )

"specific fragment passed as an attribute" means the specific fragment out of many more fragments in the JSP page on which <jsp:invoke> has to be applied.


Hope it might have clarified some of your doubts, feel free to share if you have any more question on this,


Thanks

Amrit Pandey
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic