struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Bloggs <nmr...@yahoo.com>
Subject Re: 2 problems with <bean:include> and <bean:write> whilst including results of action in page and behind firewall with NAT.
Date Tue, 04 Nov 2003 13:22:49 GMT
Kris

I am not using any <logic:forward> tags anywhere.  The
only logic tags I use are <logic:messagesPresent>.

As for the side note: I was thinking of moving to
Tiles very soon but I did not want confuse myself
further by introducing additional changes.  I.e. I
have not used Tiles before.
(I am currently reading Chap 11 (Developing with
Tiles) of Ted Husted's book.  In section 11.1.1 he
mentions "A dynamic include folds the output of the
included page into the original page." he is talking
about <jsp:include in the introduction to Tiles 
before talking about Tiles properly.)

Do you think the problem is due to the fact the I am
using templates?

Fred
--- Kris Schneider <kris@dotech.com> wrote:
> Are you using a <logic:forward> tag anywhere in the
> JSP, or a scriptlet that
> effectively performs a RequestDispatcher.forward?
> 
> On a side note, I'd recommend ditching the template
> tags in favor of the more
> basic <jsp:include> or Tiles. For Struts 1.1, the
> template stuff has been
> deprecated.
> 
> Quoting Fred Bloggs <nmr7up@yahoo.com>:
> 
> > Kris
> > 
> > Thank you for your prompt response.  I have now
> tried
> > all your suggestions but unfortunately they do not
> > work.
> > 
> > When I tried 
> > 
> > <global-forwards>
> >   <forward name="mostRecentNews"
> > path="/getmostrecentnews.do"/>
> >   ...
> > </global-forwards>
> > And then used it in the page:
> > 
> > <bean:include id="GetMostRecentPosts" 
> > forward="mostRecentNews"/>
> > 
> > When I access the site from outside the firewall I
> > still get the "Exception opening resource" and the
> > external IP address is shown in the URL.  And yet
> the
> > rest of the site works, and when I access the
> action
> > directly in my browser it displays the page
> correctly.
> > (btw it complains if I did not use the id
> parameter)
> > 
> > I then tried your next suggestion of using JSTL
> > 
> > <%@ taglib prefix="c
> > uri="http://java.sun.com/jstl/core" %>
> > ...
> > <c:import url="/getmostrecentnews.do"/>
> > 
> > It throws an exception of
> > "javax.servlet.ServletException: Cannot forward
> after
> > response has been committed" -The same as for a
> > <jsp:include ... 
> > 
> > Any further help will be greatly appreciated.
> > 
> > Thanks
> > 
> > Fred
> > 
> > --- Kris Schneider <kris@dotech.com> wrote:
> > > #2 first. Try using <bean:include
> forward="..."/>
> > > instead. You'll have to add a
> > > global forward to your struts config file, like:
> > > 
> > > <global-forwards>
> > >   <forward name="mostRecentNews"
> > > path="/getmostrecentnews.do"/>
> > >   ...
> > > </global-forwards>
> > > 
> > > And then use it in a page like:
> > > 
> > > <bean:include forward="mostRecentNews"/>
> > > 
> > > You don't need to use the "id" attribute unless
> you
> > > really want to store the
> > > included response in a variable. Try that first
> and
> > > see if #1 is still a problem
> > > (although I seem to remember there might
> actually be
> > > a bug with encoding).
> > > 
> > > Another alternative would be to try JSTL (JSP
> 1.2):
> > > 
> > > <%@ taglib prefix="c
> > > uri="http://java.sun.com/jstl/core" %>
> > > ...
> > > <c:import url="/getmostrecentnews.do"/>
> > > 
> > > The <c:import> tag also supports a
> "charEncoding"
> > > attribute that you can try if
> > > it doesn't work without it.
> > > 
> > > Quoting Fred Bloggs <nmr7up@yahoo.com>:
> > > 
> > > > Dear All,
> > > > 
> > > > I'm relatively new to Struts and have come
> across
> > > two
> > > > problems that have completely confused me.
> > > > 
> > > > I am using Struts 1.1, Tomcat 4.1.27. 
> > > > 
> > > > Problem 1:
> > > > 
> > > > I have an action that produces the most recent
> > > "news"
> > > > and displays it on separate page.  However I
> want
> > > to
> > > > include those news as well on some of my other
> > > pages. 
> > > > I use the template tags to get and put the
> various
> > > > pages together (I haven't tried Tiles yet, I
> want
> > > to
> > > > keep it simple).
> > > > 
> > > > So my topical.jsp contains a table with the
> > > following
> > > > row:
> > > > 
> > > > ...
> > > > <tr>
> > > >         <td>
> > > >                 <bean:include
> > > id="GetMostRecentNews"
> > > > page="/getmostrecentnews.do"/>
> > > >                 <bean:write
> > > name="GetMostRecentNews"
> > > > filter="false"/>
> > > >         </td>
> > > > </tr>
> > > > ...
> > > > 
> > > > All my pages use the UTF-8  charset thus I use
> the
> > > > following at the start of every jsp page:
> > > > 
> > > > <%@ page contentType="text/html;
> charset=UTF-8" %>
> > > > <%@ taglib uri="/WEB-INF/struts-bean.tld"
> > > > prefix="bean"%>
> > > > ... plus other taglib definitions.
> > > > 
> > > > When I invoke the /getmostrecentnews.do
> directly
> > > using
> > > > a browser, everything is diasplayed correctly.
> 
> > > The
> > > > correct charset is used.
> > > > 
> > > > Now when I do the <bean:include and
> <bean:write
> > > (as
> > > > shown above), the page is included in the main
> > > page,
> > > > but the charset is incorrect and thus some
> > > characters
> > > > are incorrectly displayed.
> > > > 
> > > > I do not use the locale setting since the
> content
> > > and
> > > > thus charset is locale independent.
> > > > 
> > > > I use templates to do my header, footer,
> sidebar
> > > etc. 
> > > > The above table is in the main "content" of my
> > > > template.
> > > > 
> > > > I tried changing my template to have another
> > > "news"
> > > > section and did a put (with a matching get) as
> > > > follows: 
> > > > 
> > > > <template:put name='news'
> > > > content='/getmostrecentnews.do' />
> > > > 
> > > > I get a "javax.servlet.ServletException:
> Cannot
> > > > forward after response has been committed".
> > > > 
> > > > I also tried using <jsp:include as suggested
> on
> > > "The
> > > > Struts User Guide"
> > > >
> > >
> >
>
http://jakarta.apache.org/struts/userGuide/building_view.html,
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message