Back to: Java Servlets Tutorials
Creating Servlet using Eclipse IDE
In this article, I am going to discuss how to Create Servlet Application using Eclipse IDE. Please read our previous article where we discussed Welcome File List in Servlet Application.
How to Create a Servlet Application using Eclipse IDE
Download Eclipse from https://www.eclipse.org/downloads/
We need to follow these steps to create a servlet example:
- Create a Dynamic web project
- create a servlet
- add servlet-api.jar file
- Run the servlet
Creating the dynamic web project
Click on File -> New -> Dynamic Web Project
Enter your project name and click “Next”.
Once you click on the Finish button, it will create the Project as shown in the below image.
For creating a servlet, explore the project by clicking the > icon -> explore the Java Resources -> right click on src -> New -> servlet
Give the Package Name and Class Nam and click on “Next”.
Uncheck all the checkboxes except doGet() -> next -> Finish.
Add jar file in Eclipse IDE
For adding a jar file, right-click on your project -> Build Path -> Configure Build Path
Click on Libraries tab in Java Build Path -> click on Add External JARs button
select the servlet-api.jar file under tomcat/lib -> Open
Click on “Apply and Close”
Now servlet has been created. Let’s create the first servlet code.
Start the Server and Deploy the project
Right-click on your project -> Run As -> Run on Server
In the next article, I am going to discuss how to Create Servlet Application using MyEclipse IDE. Here, in this article, I try to explain how to Create Servlet Application using Eclipse IDE. I hope you enjoy this Create Servlet Application using the Eclipse IDE article.