You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rickard Öberg <ri...@xpedio.com> on 2001/10/27 16:13:33 UTC

Tomcat4, taglibs, and pageContext.include

Hi!

Due to some recent subtle changes in Tomcat (Jasper and servlet API to 
be precise) it is no longer possible to implement jsp:include tags. This 
now results in the infamous "May not flush in custom tags" (or similar) 
error message.

Two questions:
* Why was this change made? (It is likely to break any include-tag ever 
written)
* How is one supposed to write such tags now? I found some code in 
Tomcat4 suggesting one should use RequestDispatcher.include along with a 
response wrapper that provides the JspWriter on getWriter, but it seems 
hackish (and won't work well with 2.2 servlet engines).

Any explanations would be appreciated. I believe it was Craig who 
committed these changes.

/Rickard



--
To unsubscribe, e-mail:  <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat4, taglibs, and pageContext.include

Posted by Rickard Öberg <ri...@xpedio.com>.
Craig R. McClanahan wrote:

> The reason for this change is a statement in the Javadocs for
> PageContext.include() that Tomcat 4 was not previously enforcing:
> 
>     The current JspWriter "out" for this JSP is flushed as a
>     side effect of this call, prior to processing the include.
> 
> Ideally, that statement would have been removed from the Javadocs for JSP
> 1.2, but it wasn't ... and now we are stuck enforcing it.  If you look at
> the code that Jasper generates for <jsp:include>, you will see that it
> indeed no longer uses the PageContext.include() method in its
> implementation.

I was fraid that this would be the case. May I humbly suggest that this 
is rather braindead >:-/ A not-so-insignificant number of tag libraries 
utilize pageContext.include in order to mimic jsp:include functionality, 
and these just broke.

I may mention that at our work I got a desperate call from our one of 
our senior architects yesterday who was just about to demo our system 
and found that everything (because of this change) was broken. The 
workaround would have been to revert back to Tomcatb7, but that had been 
removed from the binary downloads... *sigh*

IMHO you should revert back to the old behaviour and leave it "buggy". 
If tag libraries have to use the other solution (the "make a response 
wrapper that returns JSP writer on getWriter and use 
RequestDispatcher.include" solution) it will produce some serious 
ugliness and unclean code, not to mention that some 2.2 servlet engines 
that don't like custom response objects will cringe.

Bad bad bad.

/Rickard



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat4, taglibs, and pageContext.include

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Sat, 27 Oct 2001, Rickard Öberg wrote:

> Date: Sat, 27 Oct 2001 16:16:15 +0200
> From: Rickard Öberg <ri...@xpedio.com>
> Reply-To: Tomcat Developers Mailing List <to...@jakarta.apache.org>
> To: Tomcat Developers Mailing List <to...@jakarta.apache.org>
> Subject: Re: Tomcat4, taglibs, and pageContext.include
>
> Rickard Öberg wrote:
>
> > Due to some recent subtle changes in Tomcat (Jasper and servlet API to
> > be precise) it is no longer possible to implement jsp:include tags.
>
>
> (clarification).. using pageContext.include.
>
> /Rickard
>

The reason for this change is a statement in the Javadocs for
PageContext.include() that Tomcat 4 was not previously enforcing:

    The current JspWriter "out" for this JSP is flushed as a
    side effect of this call, prior to processing the include.

Ideally, that statement would have been removed from the Javadocs for JSP
1.2, but it wasn't ... and now we are stuck enforcing it.  If you look at
the code that Jasper generates for <jsp:include>, you will see that it
indeed no longer uses the PageContext.include() method in its
implementation.

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Tomcat4, taglibs, and pageContext.include

Posted by Rickard Öberg <ri...@xpedio.com>.
Rickard Öberg wrote:

> Due to some recent subtle changes in Tomcat (Jasper and servlet API to 
> be precise) it is no longer possible to implement jsp:include tags. 


(clarification).. using pageContext.include.

/Rickard



--
To unsubscribe, e-mail:  <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tomcat4, taglibs, and pageContext.include

Posted by Deacon Marcus <de...@wwtech.pl>.
Hi,

> -----Original Message-----
> From: Deacon Marcus [mailto:deacon_marcus@wwtech.pl]
> Sent: Monday, November 12, 2001 10:42 PM
> To: Tomcat Developers Mailing List
> Subject: RE: Tomcat4, taglibs, and pageContext.include
>
>
> Hi,
> I need to upgrade to latest T4 ASAP, and I need to have my tags working...
> ;/
> So, I guess I must get source and recompile after downgrading a
> few files -
> could you please recommend what files exactly I need to "downgrade" and to
> what versions to get rid of the mentioned "feature"?
> And, maybe the problem's worth a paragraph or two (plus links to
> downloadable patch) in FAQ?

Would it be enough to change:

    public void include(String relativeUrlPath)
        throws ServletException, IOException
    {
        JspRuntimeLibrary.include((HttpServletRequest) request,
                                  (HttpServletResponse) response,

// FROM:
                                  relativeUrlPath, out, true);

// TO:
                                  relativeUrlPath, out, false);
        /*
        String path = getAbsolutePathRelativeToContext(relativeUrlPath);
        context.getRequestDispatcher(path).include(
	    request, new ServletResponseWrapperInclude(response, out));
        */
    }

In org.apache.jasper.runtime.PageContextImpl ?

Greetings, deacon Marcus

>
> > -----Original Message-----
> > From: Rickard Öberg [mailto:rickard@xpedio.com]
> > Sent: Saturday, October 27, 2001 4:14 PM
> > To: tomcat-dev@jakarta.apache.org
> > Subject: Tomcat4, taglibs, and pageContext.include
> >
> >
> > Hi!
> >
> > Due to some recent subtle changes in Tomcat (Jasper and servlet API to
> > be precise) it is no longer possible to implement jsp:include tags. This
> > now results in the infamous "May not flush in custom tags" (or similar)
> > error message.
> >
> > Two questions:
> > * Why was this change made? (It is likely to break any include-tag ever
> > written)
> > * How is one supposed to write such tags now? I found some code in
> > Tomcat4 suggesting one should use RequestDispatcher.include along with a
> > response wrapper that provides the JspWriter on getWriter, but it seems
> > hackish (and won't work well with 2.2 servlet engines).
> >
> > Any explanations would be appreciated. I believe it was Craig who
> > committed these changes.
> >
> > /Rickard
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Tomcat4, taglibs, and pageContext.include

Posted by Deacon Marcus <de...@wwtech.pl>.
Hi,
I need to upgrade to latest T4 ASAP, and I need to have my tags working...
;/
So, I guess I must get source and recompile after downgrading a few files -
could you please recommend what files exactly I need to "downgrade" and to
what versions to get rid of the mentioned "feature"?
And, maybe the problem's worth a paragraph or two (plus links to
downloadable patch) in FAQ?

Greetings, deacon Marcus

> -----Original Message-----
> From: Rickard Öberg [mailto:rickard@xpedio.com]
> Sent: Saturday, October 27, 2001 4:14 PM
> To: tomcat-dev@jakarta.apache.org
> Subject: Tomcat4, taglibs, and pageContext.include
>
>
> Hi!
>
> Due to some recent subtle changes in Tomcat (Jasper and servlet API to
> be precise) it is no longer possible to implement jsp:include tags. This
> now results in the infamous "May not flush in custom tags" (or similar)
> error message.
>
> Two questions:
> * Why was this change made? (It is likely to break any include-tag ever
> written)
> * How is one supposed to write such tags now? I found some code in
> Tomcat4 suggesting one should use RequestDispatcher.include along with a
> response wrapper that provides the JspWriter on getWriter, but it seems
> hackish (and won't work well with 2.2 servlet engines).
>
> Any explanations would be appreciated. I believe it was Craig who
> committed these changes.
>
> /Rickard
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>