You can use HTTP servlet api for that porpose
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.53</version>
</dependency>
And you can make an web.xml that points to your servlet out of this api
<servlet>
<servlet-name> <ServletName> </servlet-name>
<servlet-class><package>.<ServletName></servlet-class>
</servlet>
<servlet-mapping>
<servlet-name><ServletName></servlet-name>
<url-pattern>/<ServletName></url-pattern>
</servlet-mapping>
and create a class that exteends from HttpServlet. e.g.
public class <ServletName> extends HttpServlet {
and implement common functions of HttpServlet class protected void doPost and protected void doGet
these functions will behave differently on different methods.
And finnaly in your pom.xml add the maven war compiler plugin
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<directory>${project.build.sourceDirectory}/main/java</directory>
<excludes>
<exclude>
**/*.java
</exclude>
</excludes>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
<archive>
</configuration>
</plugin>
</plugins>
then if you are using Eclipse you can start local server and move the created war file to
tomcat/webapps
and then restrat the tomcat. Now if you navigate to localhost you can see the deployed web application
Note: If your server running on Linux, tomcat is usually intalled in `
/usr/local/tomcat
directory. To deploy the war file you will need to copy your war file to /usr/local/tomcat and restart the tomcat using /usr/local/tomcat/bin/shutdown.sh to stop tomcat service and /usr/local/tomcat/bin/startup.sh to start it.
Hope it will help. Regards, Erik