You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Wilson, Wayne" <ww...@ettain.com> on 2001/12/28 18:06:57 UTC
New entities in struts-config?
Hi,
In order to be able to toggle back and forth between secure and insecure
mode (https & http) I have had to use some static URLs in the
global-forwards section of the struts-config. Since this app gets deployed
into multiple environments (with different hostnames) I would like an easier
way to update my struts-config with the hostnames. I created a custom dtd
(and pointed the struts-config at it) with a new HOST entity (and a
reference to the existing dtd for all the rest):
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ENTITY HOST "localhost">
<!ENTITY % struts-config SYSTEM
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
which I used in my path attribute in a forward tag in the struts-config:
<global-forwards>
<forward name="test1" redirect="true" path="http://&HOST;/test.jsp"/>
<forward name="test2" redirect="true" path="https://&HOST;/test.jsp"/>
</global-forwards>
This worked fine when opened up the struts-config.xml in IE, but Tomcat
(Struts) complained that HOST wasn't defined. Is the digester going straight
to the "official" dtd and ignoring mine? Does anyone know what I am doing
wrong or how else I can do this type of replacement in the struts-config?
Thanks,
Wayne Wilson
Re: New entities in struts-config?
Posted by Ted Husted <hu...@apache.org>.
Deft handling of HTTPS is a blind spot in the framework. I do think we
need a better all-around solution for this. For now, you could set up
alternate struts-config's for each host, and then edit the web.xml when
its deployed. But that's really messy. The entity in the DTD is a clever
idea but that also requires editing the configuration after it is
deployed.
Another alternative would be to use a utility method in the Action which
turned the context relative path into an absolute path using a specified
scheme and port. Something that looked like this:
ActionForward newForwardAbsolute( HttpServletRequest request,
ActionForward forward, String scheme, String port);
So this would return a new ActionForward based on the first, but with an
adjusted path.
In the Action, you could call it like this:
return newForwardAbsolute(request, mapping.findForward("continue"),
"HTTPS", "");
If you do anything like this, please consider contributing it back to
the community as an enhancement request to RequestUtils.
http://nagoya.apache.org/bugzilla/
"Wilson, Wayne" wrote:
>
> Hi,
>
> In order to be able to toggle back and forth between secure and insecure
> mode (https & http) I have had to use some static URLs in the
> global-forwards section of the struts-config. Since this app gets deployed
> into multiple environments (with different hostnames) I would like an easier
> way to update my struts-config with the hostnames. I created a custom dtd
> (and pointed the struts-config at it) with a new HOST entity (and a
> reference to the existing dtd for all the rest):
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!ENTITY HOST "localhost">
> <!ENTITY % struts-config SYSTEM
> "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
>
>
>
> which I used in my path attribute in a forward tag in the struts-config:
>
> <global-forwards>
> <forward name="test1" redirect="true" path="http://&HOST;/test.jsp"/>
> <forward name="test2" redirect="true" path="https://&HOST;/test.jsp"/>
> </global-forwards>
>
>
>
> This worked fine when opened up the struts-config.xml in IE, but Tomcat
> (Struts) complained that HOST wasn't defined. Is the digester going straight
> to the "official" dtd and ignoring mine? Does anyone know what I am doing
> wrong or how else I can do this type of replacement in the struts-config?
>
> Thanks,
>
> Wayne Wilson
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>