In this article, we will demonstrate a basic program, which helps to print hello servlets using the Java servlets. In order to do so, we add the JAR file.

The following program, demonstrate the sample code structure of a servlet example to show Hello World. This program also contains HTML code for designing the page and the contents.

Here we have created a servlet that extends the HttpServlet class. In this code we are inheriting the HttpServlet class and providing the implementation of the doGet() method. doGet() method is used to get the object.

Let’s take a look at the project structure:




For compiling the Servlet, jar file is required to be loaded. To import jar file in your Eclipse IDE, we will follow these steps.

  1. Right click on your project.
  2. Select Build Path.
  3. Click on Configure Build Path.
  4. Click on Libraries and select Add External JARs.
  5. Select the jar file from the required folder.
  6. Click and Apply and Ok.

Contributed by Poonam Tomar

Full stack Java Developer

   Buy me a coffee!



Download file

Leave a Reply

Notify of
Close Menu