views:

156

answers:

2

I created a web application in Netbeans, and it packages the application in a file called "aa-bb.war". When I run the project in netbeans, I can access it at "localhost:8080/aa/bb". This is all good.

Moving the .war file into a standard tomcat installation though, gives me problems. When I drop the .war into the "webapp" directory, it gets exploded into "webapp/aa-bb", but what I really want is "webapp/aa/bb" (note the "-" vs "/" in between "aa" and "bb")... so bb should be in a subdirectory of "aa".

My understanding of this is because tomcat uses the filename of the .war to create the exploded dir, and so since the war is called "aa-bb", it obviously uses the hyphen. My "context.xml" file does have the correct path "aa/bb", but I've read that Tomcat 5+ will ignore the context path specified in the .war and create a path based on filename instead.

How can I force tomcat to use a subdirectory (it may seem like a small difference in the resulting url ("aa-bb" vs "aa/bb"), but it actually is a big problem for reasons that I won't get into right now (just complicates things).

Thanks...

A: 

The standard deployment structure of tomcat is that all applications are at the first level hierarchy. Any context.war file you drop in your applications folder would eventually become accessible via http://host/context. I'm pretty sure that you can't force the subdirectory aa/bb you mention but you could trick the implementation by: (1) making application aa.war , (2) creating a directory within your aa application called bb that has all your jsps, and (3) if you have servlets or filters then also change the mapping of those to bb/servlet.

rmarimon
That's interesting, never tried that... I'm using netbeans for the packaging though, do you have any idea how to get netbeans / ant to dump everything into a subdirectory "bb"?
A: 

What options do you have? I didn't know that Tomcat disregards the path="" lately.

  1. Put apache in front and use mod_redirect or mod_proxy to funnel requests for aa/bb in Apache to aa-bb in Tomcat.

  2. Use the UrlRewriteFilter iside the webapp, depending on whatever web framework you're using(if any?). Call your webapp aa.war, then tell UrlRewriteFilter to funnel requests for /bb/ inside the app to just / instead.

lucas