How to start with Servlets, Write a servlet program to print the name coming from a HTML form.
Before we start with servlets , make sure you have following software installed.
- Apache Tomcat 7.0
- Java 1.7 or higher
Create a folder structure as shown below under C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps directory.
- Create a file say HelloWorld.java and placed it in the classes folder.
- compile the HelloWorld.java file.
- edit the web.xml file as given below.
- Create a Hello.html file and place it in HelloWorld i.e. root folder.
- Run the Tomcat Server.
- Navigate to the following URL.
You should see the Hello.html web page on your browser.
- Enter your Name in the text field and click submit.
- You should see the result something like below.
If you run into any error, please feel free to reach us.