Sample program to print hello world in servlets - Example
A Java servlet is a Java program that extends the capabilities of a server. Although servletscan respond to any types of requests, they most commonly implement applications hosted on Web servers. - Wiki
Just a small introduction from my side-
A Servelt contains following modules-
init() - For initialisation
service() - For performing the services
destroy() - servlets are destroyed using this fucntion
Sample program-
(I am using netbeans here for the example)
Open netbeans and add a new project as shown below-
Now we need to create a servlet, so
Right click on the project>New > Servlets
and click on finish.
Now your servlet is ready to run. Right click on your servlet file and click on run
It will open up the default browser and you can see the sample program running there.
By default the netbeans will provide some sample text to print in the server page.
Comments
Post a Comment