tags:

views:

28

answers:

2

Hello,

When I start up tomcat, it starts serving out of localhost:8080/. I would like it to start serving out of localhost:8080/aaa. I dont want to replace the "root" webapp with the "aaa" webapp, I want tomcat to treat "/aaa" like "/" in the sense that before where I could do something like

  • localhost:8080/ --> root webapp
  • localhost:8080/webapp1 --> webapp1
  • etc.

I now want to do something like:

  • localhost:8080/aaa ---> root webapp
  • localhost:8080/aaa/webapp1 --> webapp1
  • etc.

Any help would be great.

A: 

I am not sure if you can do this with Tomcat only, but this is usually achieved with Apache mod_proxy.

kgiannakakis
A: 

There is a solution but this is an ugly one and not recommended by Tomcat docs (i.e. adding Context in server.xml is not recommended). This is okay for you to test out on your current server.

You can set these in your Tomcat server.xml.

Add a <Context> element within the <Host> like below and set the path as your "/aaa" prefix

This should allow you to access http: //localhost:8080/aaa will directly take you to webapp "root"

<Context docBase="rootwebapp" path="/aaa" reloadable="true"  />

Add another Context with the path to "/aaa/webapp1" like below should allow you to access webapp1 as http: //localhost:8080/aaa/webapp1

<Context docBase="webapp1" path="/aaa/webapp1" reloadable="true"  />
JoseK