You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nathan Eric Probst <pr...@pond.net> on 2001/01/15 13:13:24 UTC
InsertTag.doEndTag problem: Illegal to flush within a custom tag
I'm using Components/Struts and I have encountered a strange problem.
Below is all the information I could think to gather. If you look in
the snippet from configureCompostition.jsp, there are two <comp:include>
blocks. The strange thing is that it is failing at the end of the
second block! So, the first one works (and I can see it's results in my
browser), but the second one throws this exception. However, as near as
I can tell, they both result in the same method calls, so I don't get
why one works and the other doesn't.
<comp:include>'s doEndTag makes the same call as the <template:insert>'s
doEndTag:
pageContext.include(something);
Although I am using Components/Struts, the same problem would seem to
exist in plain-vanilla Struts. So, maybe someone here knows the answer?
Any help you can provide is much appreciated!
Thanks,
Nathan
P.S. I'm running Tomcat 3.2.1 and JDK1.3, if that matters.
Here is the top of the stack trace:
-----------------------------------
Can't include page '/layouts/tabbedBoxLayout.jsp' : Illegal to flush
within a custom tag
java.io.IOException: Illegal to flush within a custom tag
at javax.servlet.jsp.tagext.BodyContent.flush(BodyContent.java:87)
at
org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:413)
at
s1.struts.taglib.component.IncludeTag$PathIncludeType.doEndTag(IncludeTag.java:614)
at s1.struts.taglib.component.IncludeTag.doEndTag(IncludeTag.java:476)
at
components._0002fcomponents_0002fconfigureComposition_0002ejspconfigureComposition_jsp_8._jspService(_0002fcomponents_0002fconfigureComposition_0002ejspconfigureComposition_jsp_8.java:309)
The important section of configureComposition.jsp:
--------------------------------------------------
<comp:include name="box.layout" flush="false">
<comp:put name="label" beanName="compositionSchema"
beanProperty="label" beanScope="request"
direct="true" />
<comp:put name="desc" beanName="compositionSchema" beanProperty="desc"
beanScope="request"
direct="true" />
</comp:include>
<logic:iterate id="layer" name="compositionSchema" property="layers"
type="com.javawebguy.jig.beans.LayerSchema" >
<comp:include name="tabbed.box.layout" flush="false">
<comp:put name="label" beanName="layer" beanProperty="label"
beanScope="page" direct="true" />
<comp:put name="desc" beanName="layer" beanProperty="desc"
beanScope="page" direct="true" />
309--> </comp:include>
The important section of IncludeTag.java:
-----------------------------------------
public void doEndTag() throws JspException
{
try {
if( InstancesUtil.userDebugLevel > InstancesUtil.NO_DEBUG )
System.out.println( "include page='" + page + "'." );
// set new context for included component.
pageContext.setAttribute( ComponentConstants.COMPONENT_CONTEXT,
subCompContext,
pageContext.REQUEST_SCOPE);
// include requested component.
if( flush )
pageContext.getOut().flush();
614--> pageContext.include(page);
}
The important section of PageContextImpl.java:
----------------------------------------------
public void include(String relativeUrlPath)
throws ServletException, IOException
{
String path = getAbsolutePathRelativeToContext(relativeUrlPath);
413--> out.flush();
context.getRequestDispatcher(path).include(request, response);
}
The important section of BodyContent.java:
-------------------------------------------
public void flush() throws IOException {
87--> throw new IOException("Illegal to flush within a custom tag");
}
Re: InsertTag.doEndTag problem: Illegal to flush within a custom tag
Posted by Nathan Eric Probst <pr...@pond.net>.
Ahhh...well, I figured out why one works and the other doesn't. The problem happens when using insert/include inside a <logic:iterate> tag, which is also a custom tag. I guess I'm stuck
with using scriplets for iteration when I want to include something multiple times. Bummer!
Nathan
Nathan Eric Probst wrote:
> I'm using Components/Struts and I have encountered a strange problem.
> Below is all the information I could think to gather. If you look in
> the snippet from configureCompostition.jsp, there are two <comp:include>
> blocks. The strange thing is that it is failing at the end of the
> second block! So, the first one works (and I can see it's results in my
> browser), but the second one throws this exception. However, as near as
> I can tell, they both result in the same method calls, so I don't get
> why one works and the other doesn't.
>
> <comp:include>'s doEndTag makes the same call as the <template:insert>'s
> doEndTag:
> pageContext.include(something);
> Although I am using Components/Struts, the same problem would seem to
> exist in plain-vanilla Struts. So, maybe someone here knows the answer?
>
> Any help you can provide is much appreciated!
>
> Thanks,
> Nathan
>
> P.S. I'm running Tomcat 3.2.1 and JDK1.3, if that matters.
>
> Here is the top of the stack trace:
> -----------------------------------
> Can't include page '/layouts/tabbedBoxLayout.jsp' : Illegal to flush
> within a custom tag
> java.io.IOException: Illegal to flush within a custom tag
> at javax.servlet.jsp.tagext.BodyContent.flush(BodyContent.java:87)
> at
> org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:413)
> at
> s1.struts.taglib.component.IncludeTag$PathIncludeType.doEndTag(IncludeTag.java:614)
> at s1.struts.taglib.component.IncludeTag.doEndTag(IncludeTag.java:476)
> at
> components._0002fcomponents_0002fconfigureComposition_0002ejspconfigureComposition_jsp_8._jspService(_0002fcomponents_0002fconfigureComposition_0002ejspconfigureComposition_jsp_8.java:309)
>
> The important section of configureComposition.jsp:
> --------------------------------------------------
> <comp:include name="box.layout" flush="false">
> <comp:put name="label" beanName="compositionSchema"
> beanProperty="label" beanScope="request"
> direct="true" />
> <comp:put name="desc" beanName="compositionSchema" beanProperty="desc"
> beanScope="request"
> direct="true" />
> </comp:include>
>
> <logic:iterate id="layer" name="compositionSchema" property="layers"
> type="com.javawebguy.jig.beans.LayerSchema" >
> <comp:include name="tabbed.box.layout" flush="false">
> <comp:put name="label" beanName="layer" beanProperty="label"
> beanScope="page" direct="true" />
>
> <comp:put name="desc" beanName="layer" beanProperty="desc"
> beanScope="page" direct="true" />
> 309--> </comp:include>
>
> The important section of IncludeTag.java:
> -----------------------------------------
> public void doEndTag() throws JspException
> {
> try {
> if( InstancesUtil.userDebugLevel > InstancesUtil.NO_DEBUG )
> System.out.println( "include page='" + page + "'." );
>
> // set new context for included component.
> pageContext.setAttribute( ComponentConstants.COMPONENT_CONTEXT,
> subCompContext,
> pageContext.REQUEST_SCOPE);
> // include requested component.
> if( flush )
> pageContext.getOut().flush();
> 614--> pageContext.include(page);
> }
>
> The important section of PageContextImpl.java:
> ----------------------------------------------
> public void include(String relativeUrlPath)
> throws ServletException, IOException
> {
> String path = getAbsolutePathRelativeToContext(relativeUrlPath);
> 413--> out.flush();
> context.getRequestDispatcher(path).include(request, response);
> }
>
> The important section of BodyContent.java:
> -------------------------------------------
> public void flush() throws IOException {
> 87--> throw new IOException("Illegal to flush within a custom tag");
> }