This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes proxypass and deployment to a production env Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "proxypass and deployment to a production env" Watch "proxypass and deployment to a production env" New topic

proxypass and deployment to a production env

Andy Westley

Joined: Nov 09, 2004
Posts: 19
I've been developing a struts app locally on my machine, accessing it directly through tomcat on port 8080:


The time has come to think about deploying it to production webserver now, and I was hoping I'd be able to hide it behind apache on the webserver using a virtual host and proxypass configuration something like:

<VirtualHost *:80>
DocumentRoot "/var/www/site_home_directory"

<Directory "/var/www/site_home_directory">
allow from all
Options +Indexes

ProxyRequests Off

ProxyPass / http://local_ip_address:8080/MyAppName/
ProxyPassReverse / http://local_ip_address:8080/MyAppName/


Which I had hoped would result in requests for forwarding on to http://ip_address:8080/MyAppName/. This has a number of advantages:

* It's simple
* I could, in future, deploy several apps to tomcat without having to take the root context
* I can packages resources such as javascript, images and css in the war and use root-relative paths to access them (even if this is a bad hing to do)

Superficially, this all appears to work fine. However, any struts-generated paths such as those that result from the <html:form> and <html:link> tags always get generated with the context name, which then breaks my proxypass.

<html:form action="/" focus="name">

results in

<form id="service" method="post" action="/MyAppName/;jsessionid=215E9DB58CEA11F6BDEFEEC07A707AB4">

while <html:link forward="site_advanced_search">Advanced search</html:link> results in

<a href="/MyAppName/;jsessionid=215E9DB58CEA11F6BDEFEEC07A707AB4">Advanced search</a>

I've spent most of the lst couple of days trying to find an answer on the web, and loads of people have asked a similar question, but there never seems to be a reasonable answer. Some have suggested not using the html taglibrary, which doesn't seem sensible. Others have suggested writing filters to strip the context name, which seems like overkill. There's also talk of using <html:base>, but I'm sure that's missing the point.

This must have been done before. I guess I'm hoping there's a config option somewhere that will force the generated paths to be root-relative.

Cany anyone help?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Sorry, Andy. No such config option exists to my knowledge.

Consultant, Sima Solutions
Andy Westley

Joined: Nov 09, 2004
Posts: 19
Can anyone suggest any practical solutions to the problem then? Is the only real answer that I'll need to deploy the app as the ROOT context? That does seem a bit of a limitation.
[ October 22, 2006: Message edited by: Andy Westley ]
I agree. Here's the link:
subject: proxypass and deployment to a production env
It's not a secret anymore!