My first ever experience in building servlet REST API.

Pasindu Rupasinghe
2 min readJul 31, 2021

Java, Maven, Mysql,Tomcat 9, IntelliJ IDEA(Ultimate version), Ubuntu 20.04

Creating a maven project.

What is Maven? Maven is a build automation tool that is mostly used in Java projects. Using maven as a build tool in my web servlet project was an amazing experience.

In Maven, a dependency is a JAR, ZIP, or another package that our current project requires to compile, build, test, and/or run. These dependencies are resolved and loaded from the local repository when we perform a build or execute a maven project. The dependencies are gathered in the pom.

The POM provides all required project information as well as plugin configurations for use throughout the build process. The build life cycle is the “when” and “how,” while it is the declarative expression of the “who,” “what,” and “where”.

Method implementation

A Java servlet does not have a main method. They include methods that you can use to hook into when a specific event occurs (For example - a click on the button, HTTP PUT request on a HttpServlet). During the creation of the servlet, I primarily focused on four methods while implementing. Those are,

  1. doPost (POST)
  2. doGet (GET)
  3. doDelete (DELETE)
  4. doUpdate (PUT)

Here is my Github repo regarding my implementation. Just Fork it and refer if you are passionate. https://github.com/pasindur99/Organizations-backend

Okay, this will be the end of the first chapter of my experience in creating java servlets. I will be soon again with another chapter on creating java servlets. Thank you for reading!! :)

--

--

Pasindu Rupasinghe

Undergraduate at University of Colombo School of Computing.