Creating First Servlet Application using Eclipse IDE
Eclipse IDE is the most popular Java IDE used in the Industry. It is developed by an open source community and can be downloaded for free from Eclipse.org
Steps to create Servlet using Eclipse IDE
To create a Servlet application in Eclipse IDE you will need to follow the following steps:
- Goto File -> New -> Dynamic Web Project
- Give a Name to your Project and click Next
- Check Generate web.xml Deployment Descriptor and click Finish
- Now, the complete directory structure of your Project will be automatically created by Eclipse IDE.
- Click on First project, go to Java Resources -> src. Right click on src select New -> Servlet
- Give Servlet class name and click Next
- Give your Servlet class a Nmae of your choice.
- Leave everything else to default and click Finish
- Now your Servlet is created, write some code inside it. You can take reference from the code in the picture below.
- Add servlet-api.jar JAR file to your project. Click on Libraries, right click on Web App Libraries select Build Path -> Configure Build Path
- Click on Add External JARs
- This JAR is now added to your project's build path.
- Select servlet-api.jar from Apache Tomcat Directory
- Now all you have to do is Start the server and run the application.