File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "proxypass and deployment to a production env" Watch "proxypass and deployment to a production env" New topic
Author

proxypass and deployment to a production env

Andy Westley
Greenhorn

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:

http://localhost:8080/MyAppName/


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>
ServerName my.domain.name
DocumentRoot "/var/www/site_home_directory"

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

ProxyRequests Off

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

</VirtualHost>

Which I had hoped would result in requests for http://my.domain.name/ 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="/executeSearch.do" focus="name">

results in

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

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

<a href="/MyAppName/advancedSearch.do;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.


Merrill
Consultant, Sima Solutions
Andy Westley
Greenhorn

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: http://aspose.com/file-tools
 
subject: proxypass and deployment to a production env