File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Difference between <jsp:invoke> and <jsp:doBody> actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Difference between <jsp:invoke> and <jsp:doBody> actions" Watch "Difference between <jsp:invoke> and <jsp:doBody> actions" New topic

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

Johnnie Smith

Joined: May 02, 2012
Posts: 23
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,
Amrit pandey

Joined: Jun 28, 2010
Posts: 19
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,


Amrit Pandey

Thanks & Regards,
Amrit Pandey
I agree. Here's the link:
subject: Difference between <jsp:invoke> and <jsp:doBody> actions
It's not a secret anymore!