This Java servlet application responds to GET and POST requests. It's built with Ant for easy compilation and packaging, and is designed to run on Apache Tomcat.
- JDK 8 or higher
- Apache Ant
- Apache Tomcat at
/usr/local/sdkman/candidates/tomcat/10.1.14
src/
: Source files for the servlet.WebContent/
: Web files and WEB-INF directory.WebContent/WEB-INF/web.xml
: Servlet configuration.build.xml
: Ant build script located at the project root.lib/
: Directory for library dependencies at the project root.
-
Include Servlet API:
- Download
servlet-api.jar
. - Place it in the
lib/
directory.
- Download
-
Build with Ant:
build.xml
should be at the root of your project directory.- Run
ant
to compile and package the application intodist/SimpleWebApp.war
.
-
Deploy on Tomcat:
- Stop Tomcat:
./catalina.sh stop
from the Tomcat bin directory. - Copy
dist/SimpleWebApp.war
to thewebapps
directory of Tomcat. - Start Tomcat:
./catalina.sh start
.
- Stop Tomcat:
-
Access the Servlet:
- Visit
http://localhost:8080/SimpleWebApp/SimpleServlet
.
- Visit
-
Test POST Method:
- Use
curl
or Postman to send a POST request to the servlet's URL.
- Use
Follow these instructions for setting up, building, and deploying your servlet application.