Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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.
 
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
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic