Hello world program in Servlet using Eclipse IDE
Requirement : Eclipse EE IDE, Tomcat.
Create Dynamic Web Project.
Check every field like this for you have installed Tomcat or if you have any other then click on New Runtime add configuration of your server. version of Dynamic module 2.5
and just click next .
then next and check the CheckBox.
click finish now you will get project structure like this
Now right click on src folder and create servlet
here provide your package name and class name and for Just Hello World Program there is no need of any super class sa I make it blank by default servlet class implements Servlet interface.
finish then you can see a servlet under your src folder and all the following entries related to servlet will automatically comes in web.xml file.
now go into your servlet class and in service method write this line response.getWriter().println("Hello Servlet");
now right click on project run as >run on server select your server and click next
First click on remove all so that only the things related to that project will execute by server.
now when program run then you will get this error so don't be panic.Its coming because we didn't create any default page so thats why its not executing .
To remove this error create 1 Html file. right click on project and create Html file name it index.html
in index.html file
you can see now .
If you like Codersarts blog and looking for Assignment help, Project help, Programming tutors help and suggestion you can send mail at email@example.com.
Please write your suggestion in comment section below if you find anything incorrect in this blog post .