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
The Eclipse is an open-source IDE famous for our Java Integrated Development Environment (IDE), but we have a number of pretty cool IDEs, including our C/C++ IDE, JavaScript/TypeScript IDE, PHP IDE, and more. You can easily combine multiple language support and other features into any of our default packages, and the Eclipse Marketplace allows for virtually unlimited customization and extension.
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”.
Click “Finish”
Once you click on the Finish button, it will create the Project as shown in the below image.
Create Servlet
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
Click “Next”
Click “Finish”
Output
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.