Servlet in Eclipse

1)Right Click on Project Explorer --> New --> Select Dynamic Web Project
Servlet select dynamic

2)Provide Project Name --> Click on Next --> Select Generate web.xml --> Finish
Servlet select generate

3)Right Click on Project -->Select New --> Select Servlet -->
Servlet select

4)Provide Package and class Name and Click on Next

Servlet next

5)Set url(/FirstServlet) and Click Next

Servlet next

6)Click on get() and post() to Create and Finish

Servlet setup finish

Servlet setup finish next

7)Set the Build path to Right click on Project and Select Properties ->Build path -->Select Libraries

Servlet build path

8)Add external jar of Servlet-api from C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.22\lib(Where your Tomcat placed)and Ok .

tomcat setup

tomcat setup next

tomcat setup next

9)Write Code on and do Entry in Web.xml

web.xml entry

web.xml entry next
10)Right Click on FirstServlet Select Run --> Run on Server

run on server

run on server next

run on server next


Servlet Output