New entities in struts-config?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Wayne_Wilson
Posted On:   Thursday, December 27, 2001 10:30 AM

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 with a HOST entity: <?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-confi   More>>

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 with a HOST entity:


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










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 the replacements in the
struts-config that I am trying to do?

Thanks,

Wayne Wilson

   <<Less

Re: New entities in struts-config?

Posted By:   Ted_Husted  
Posted On:   Monday, December 31, 2001 03:51 AM

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.



HTH - Ted

About | Sitemap | Contact