Reputation: 33192
I'm currently developing a Java web application myapp and when deployed in Tomcat 6 server, I access myapp with this URL: http://localhost:8080/myapp
Instead I want to access my application using this URL: http://myapp:8080
since myapp will be the only application deployed in my Tomcat 6.
How do I do it?
Upvotes: 3
Views: 2470
Reputation: 1109542
This can be done in Tomcat in basically two ways:
Set path
attribute of <Context>
element in Webapp/META-INF/context.xml
(or Tomcat/conf/server.xml
, depending where you'd like to define it) to an empty String. E.g.
<Context path="">
Rename it to ROOT.war
and Tomcat will automagically deploy it as ROOT.
Outside Tomcat there are more ways to do this, such as (virtual) proxy, URL rewriting with .htaccess
, etcetera.
Upvotes: 4
Reputation: 61
Im assuming you meen you want your url to be http://localhost:8080 not http://myapp:8080.
If you dont need the default apps that come with tomcat then just go to your webapps directory (where myapp is probably located) and look for another folder called ROOT (in my Tomcat 6). rename ROOT to something else and rename myapp to ROOT. This is a quick and messy way that works because the default host's appBase is webapps and the default app is ROOT.
If you had access to the tomcat/conf/ directory then you could edit the server.xml file but Im not very knowledgeable about server.xml so I wont try and walk you through it.
Upvotes: 2