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 11:40:40 GMT
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,
> > but I just get an exception
> > "javax.servlet.ServletException: Cannot forward
> after
> > response has been committed".
> > 
> > I have not yet ported my application to Tiles so I
> > don't know if using Tiles instead of Templates
> will
> > solve my problem.
> > 
> > I would be grateful for any pointers.
> > 
> > Problem 2:
> > 
> > My site is behind a firewall that does NAT.  The
> site
> > works, except for the jsp pages where I do:
> > 
> > <tr>
> >         <td>
> >                 <bean:include
> id="GetMostRecentNews"
> > page="/getmostrecentnews.do"/>
> >                 <bean:write
> name="GetMostRecentNews"
> > filter="false"/>
> >         </td>
> > </tr>
> > 
> > It appears that the <bean:include changes the 
> > /getmostrecentnews.do to an absolute URL. 
> However,
> > since I am behind a NAT firewall (doing port
> > forwarding) I get an exception saying that
> "Exception
> > opening resource" since the absolute URL contains
> the
> > external IP and not the NATed IP address of the
> tomcat
> > server.
> > 
> > I tried <html:base/> in all the jsp pages, but
> that
> > does not seem to help.
> > 
> > Is there anyway to tell the <bean:include not to
> use
> > an absolute address but a relative address to the
> > application or context?
> > 
> > I would be grateful for any help or pointers.
> > 
> > Thank you in advance.
> 
> -- 
> Kris Schneider <mailto:kris@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
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