You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Immanuel, Gidado-Yisa" <av...@cdc.gov> on 2001/05/03 21:02:58 UTC
Clarification on behavior of
Consider the following JSP Pages
Main.jsp
--------
<%@ taglib uri="bean" prefix="bean" %>
<bean:define id="poweredbyTitle"
value="<h2>Economic Report By County</h2>"
toScope="request" />
<jsp:include page="PoweredBy.jsp" flush="true"/>
PoweredBy.jsp
-------------
<%@ taglib uri="bean" prefix="bean" %>
<bean:write name="poweredbyTitle" filter="false"/>
Is Powered By...
The 'bean:write' is able to find 'poweredbyTitle' in
request scope. However, if I use the following 'Main.jsp'
page with 'bean:include':
Main.jsp<2>
-----------
<%@ taglib uri="bean" prefix="bean" %>
<bean:define id="poweredbyTitle"
value="<h2>Economic Report By County</h2>"
toScope="request" />
<bean:include id="poweredby" forward="poweredby" />
Assuming correct Global Forward...the 'PoweredBy.jsp' page
is not able to locate find the attribute 'poweredbyTitle'
in any scope (as far as I can tell), and an empty String
is printed. Note that if I use (in Main.jsp)
'toScope="session"' instead, it all works fine.
Is this the expected behavior, or a bug? (I'll make the
appropiate bug-report if necessary.)
Thanks,
Gidado
p.s. From looking at org.apache.struts.taglib.IncludeTag:
public int doStartTag() throws JspException {
URL url = hyperlink();
URLConnection conn = null;
try {
conn = url.openConnection();
conn.setAllowUserInteraction(false);
conn.setDoInput(true);
conn.setDoOutput(false);
conn.connect();
it is apparent that there is no use of a RequestDispatcher
(which, I'm assuming, would help in keeping track of
'request' scoped attributes).
Re: Clarification on behavior of
Posted by "Craig R. McClanahan" <cr...@apache.org>.
Unfortunately, you won't be able to use request scope for this. The
reason is that, in a JSP 1.1 environment, <bean:include> has to internally
do a separate request in order to buffer the output. Because it is a
separate request, request scope attributes are not shared.
Once we can migrate to Servlet 2.3 / JSP 1.2, it will be possible to
implement <bean:include> so that is shares the same request.
Craig
On Thu, 3 May 2001, Immanuel, Gidado-Yisa wrote:
> Consider the following JSP Pages
>
> Main.jsp
> --------
> <%@ taglib uri="bean" prefix="bean" %>
>
> <bean:define id="poweredbyTitle"
> value="<h2>Economic Report By County</h2>"
> toScope="request" />
>
> <jsp:include page="PoweredBy.jsp" flush="true"/>
>
>
> PoweredBy.jsp
> -------------
> <%@ taglib uri="bean" prefix="bean" %>
>
> <bean:write name="poweredbyTitle" filter="false"/>
> Is Powered By...
>
>
> The 'bean:write' is able to find 'poweredbyTitle' in
> request scope. However, if I use the following 'Main.jsp'
> page with 'bean:include':
>
> Main.jsp<2>
> -----------
> <%@ taglib uri="bean" prefix="bean" %>
>
> <bean:define id="poweredbyTitle"
> value="<h2>Economic Report By County</h2>"
> toScope="request" />
>
> <bean:include id="poweredby" forward="poweredby" />
>
> Assuming correct Global Forward...the 'PoweredBy.jsp' page
> is not able to locate find the attribute 'poweredbyTitle'
> in any scope (as far as I can tell), and an empty String
> is printed. Note that if I use (in Main.jsp)
> 'toScope="session"' instead, it all works fine.
>
> Is this the expected behavior, or a bug? (I'll make the
> appropiate bug-report if necessary.)
>
> Thanks,
> Gidado
>
> p.s. From looking at org.apache.struts.taglib.IncludeTag:
>
> public int doStartTag() throws JspException {
> URL url = hyperlink();
> URLConnection conn = null;
> try {
> conn = url.openConnection();
> conn.setAllowUserInteraction(false);
> conn.setDoInput(true);
> conn.setDoOutput(false);
> conn.connect();
>
> it is apparent that there is no use of a RequestDispatcher
> (which, I'm assuming, would help in keeping track of
> 'request' scoped attributes).
>