tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Tang" <>
Subject Re: Using a jsp:include action (JSP 1.1) within a BodyTag taglib tag
Date Tue, 30 Jan 2001 19:48:56 GMT
Thanks.  This sounds like a decent workaround.

Can you send examples of how you've got this working?

Does the included JSP file need to do anything 'special' to work in your

Thanks again.


"Ward, Jeff" wrote:

>   Yup, it's part of the spec to do that. The include writes directly to the
> request while the tag writes to the body. (which is buffered until the end
> in which case it is written to it's parent or if no parent then the
> request.) The only way I have found to get around this is to write my own
> include and included page tags.
>   My include stuffs the current out into the request and then calls the
> included page. The included page tag grabs the out from the request and
> writes to it instead of the request, the result is an inline include.
>   Another way is to have an include that uses a URL and writes the result
> inline. The upside is you don't need the included page tags but the down
> side is it isn't an include in the JSP since anymore (it has a different
> request) and it takes more resources (it is another hit to your site).
>   This is just an ugliness in the spec because they didn't think about
> nested tags that deeply.
>   Hope this helps.
>   -Jeff Ward
>  -----Original Message-----
> From:   Alex Tang []
> Sent:   Tuesday, January 30, 2001 10:16 AM
> To:
> Cc:
> Subject:        Using a jsp:include action (JSP 1.1) within a BodyTag taglib
> tag
> hi folks.  (Sorry for the wide distribution, this question seems to span
> both the JSP and taglib realm).
> I'm having a problem with the interaction of a taglib BodyTag and a
> jsp:include action (or an equivalent taglib tag that uses a
> pageContext.forward()).  For example, if I have:
>      <foo:myBodyTag>
>        Blah Blah...
>        <jsp:include page="..."/>
>      </foo:myBodyTag>
> The output from the jsp:include action always appears BEFORE the output
> from the myBodyTag taglib tag.
> (BTW, I'm using Tomcat 3.1)
> In reading the JSP 1.1 spec, section 5.4.5 says
>      The BodyContent Class
>      The BodyContent is a subclass of JspWriter that can be used to
>      process body evaluations so they can retrieved later on. The
>      class has methods to convert its contents into a String, to
>      read its contents, and to clear the contents.
>      The buffer size of a BodyContent object is "unbounded". A
>      BodyContent object cannot be in autoFlush mode. It is not
>      possible to invoke flush on a BodyContent object, as there is
>      no backing stream. This means that it is not legal to do a
>      jsp:include when out is not bound to the top-level JspWriter.
>      ...
> >From the last sentence, does this mean that it is illegal to use a
> jsp:include action (or an equivalent taglib tag that performs a
> pageContext.include()) within a BodyTag?
> Is there a way to get around this in JSP 1.1 (Specifically Tomcat 3.x)?
> Would setting the page buffer to none help?  (If so, what problems or
> drawbacks are there for settign the page buffer to none?)
> I've looked through the JSP 1.2 spec (although not completely), and I
> did not see any mention of this type of restriction.  Is this correct?
> I realize that this is somewhat contanier specific, but does anyone know
> if Tomcat 4.x allow for jsp:include actions within a BodyTag?
> Thank you for your time.
> ...alex...

View raw message