struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Bloggs <nmr...@yahoo.com>
Subject 2 problems with <bean:include> and <bean:write> whilst including results of action in page and behind firewall with NAT.
Date Mon, 03 Nov 2003 13:34:50 GMT
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.

__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
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