1. File→ New→ Dynamic Web Project→ specify the Project Name as anything you want.
2. Next→ next→ then select generate web.xml deployment descriptor→ finish→ it will add a project in the explorer.
3. Now start your tomcat server by right clicking and select the start.
4. Go to project explorer and select your servlet→ right click on it→ new→ servlet.
5. Go in project explorer and select your servlet→ right click on it→ new→ servlet→ now give the package name as I had given as com.rakhee.demo.
6. Give the class name as Firstservlet→ next→ next.
7. Now select what functions you want to add in the servlet. Like I want to add doGet().
8. After click it finish it will open a coding sheet in which we have to code the doGet() method like the below coding. When we write PrintWriter it will show an error. To remove it place cursor on it PrintWriter and import the package required for it.
9. Now select the run button and select run on server. If there is no error it will execute the servlet on localhost 8080 port.
10. The output is