You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Sergio Socarras <so...@yahoo.com> on 2000/09/07 22:08:05 UTC

JSP include/forward and tags problem. PLEASE HELP!

Hi All,

I wish to use the PageContext.include(...) API from
one of my tags. The tag is nested in bodies of other
tags. When I use the PageContext.include(...) the
output goes directly to the ServletResponce output
stream (as per spec jsp1.2 or jsp.1.1), and not to the
BodyContent of the tag within which it is nested.

For example, if <sls:tag> produces string called "foo"
(from doStartTag method), and <sls:include> executes
PageContext.include("bar.html") method to include a
page containing "bar" I would expect the following
nesting:

 <sls:tag>
   <sls:tag>
      <sls:include />
   </sls:tag>
 </sls:tag>
 
 To produce the following output:
 
 foo
 foo
 bar
 
 Instead, the following output is produced:
 
 bar
 foo
 foo
 
 It does not matter how deep I nest the sls:include,
it always comes out first, because the bodies of
surrounding tags do not get a chance to output until
the last </sls:tag> executes
"bodyContent.writeOut(bodyContent.getEnclosingWriter());".
 This problem is due to the spec indicating that:
 
 include
 public abstract void include(java.lang.String
relativeUrlPath)
                       throws ServletException
 <../../../javax/servlet/ServletException.html>,
                              java.io.IOException
 Causes the resource specified to be processed as part
of the current ServletRequest and ServletResponse
being processed by the calling Thread. The output of
the target resources processing of the request is
written directly to the ServletResponse output stream.


Is it possible that the spec needs to change to allow
PageContext.include (and forward for that matter) to
honor the current nesting of the BodyContext as
defined by the series of pushBody() api calls prior to
the call of the PageContext.include API.

Please correct me if I am wrong.
 
Thanks.
 -Sergio

__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

Re: JSP include/forward and tags problem. PLEASE HELP!

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Sergio Socarras wrote:

> [snip]
> Is it possible that the spec needs to change to allow
> PageContext.include (and forward for that matter) to
> honor the current nesting of the BodyContext as
> defined by the series of pushBody() api calls prior to
> the call of the PageContext.include API.
>

The ability to buffer the response returned by an include you are talking
about is in fact present in the Servlet 2.3 and JSP 1.2 specifications
(although not in the precise manner that you describe), that are
currently in public review and available at the JavaSoft web site
(<http://java.sun.com/products/servlet> and
<http://java.sun.com/products/jsp>).  The corresponding functional
changes to Tomcat will be available in version 4.0.

>
> Please correct me if I am wrong.
>
> Thanks.
>  -Sergio
>

Craig McClanahan


>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: general-help@jakarta.apache.org

--
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat