I am trying to deploy a web application on a hosting (there is a volume there). By default, tomcat provides context to the application equal to the name of the war'nik, which I compile with a maven. Those. To open my application in the address bar, we write something like сайт.com/имяWAR , but we need сайт.com , i.e. How to redefine the context from the имяWAR to / ? This should be done in the application code, since I don’t have access to tomkat on the hosting and put the contex path in / I cannot set there for my war'nik

enter image description here

  • Doesn’t tomket automatically have to deploy your application and show it to the address without any / * war? In any case, you need to look at the tomkote settings on the machine - GenCloud
  • Automatically tomkat deploit application at the address 'localhost: 8080 / name WAR' (seen in the table in the photo, arrow 1), this path can be changed by standard means tomkat (look at the photo, arrow 2) by setting Contex Path (required) to '/'. But there is no such possibility on hosting, and besides, if I deploy two applications, Tomkat does not allow installing the '/' path to both. You need to install the path to the application, for example in pom.xml, i.e. in the application code. - user_Kyrt

1 answer 1

As far as I remember, you need to use the special name ROOT for your WAR file, i.e. it should be called ROOT.war

  • In pom.xml, I did this <build> <finalName>ROOT</finalName> <plugins> .... </plugins> </build> now when I go to localhost: 8080, it’s not the start page of Tomkom, but my application, hosted have not tried yet. - user_Kyrt 7:02
  • I tried to do the same thing on the hosting - it does not work, the site opens only when adding /ROOT to the path. The site nice.biz.ua , war archive filled under the name nc . If you follow the link nice.biz.ua - then nothing works, if so nice.biz.ua/nc - then all the rules. - user_Kyrt 6:08
  • And why did you upload the file "under the name nc"? - Slava Semushin
  • But as? By default, the maven collects according to the artifactID and version, it looks like nice-1.0 , for simplicity it was renamed to nc - user_Kyrt
  • Added the plugin <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/</path> </configuration> </plugin> and everything seemed to work, but the session began to be reset, i.e. I log in to another page and the authorization flies and with it all the attributes transferred by the servlet to the model. ?? - user_Kyrt