A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Simple project in servlet

write the following code and follow the steps as below:


<form action="welcome" method="get">
Enter your name<input type="text" name="name"><br>

<input type="submit" value="login">







import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class HEERA extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
PrintWriter pw=res.getWriter();
String name=req.getParameter("name");
pw.println("Welcome "+name);

now compile the above folder as below:

Now to complete the project follow the hierarchy of file:

step1. create a folder and name the folder as your project name.
folder name; HEERA

step2. make index.html and WEB-INF in HEERA folder

step3. Create web.xml and a folder classes in WEB-INF

step4. copy the HEERA.class file in classes folder.

Finally,  project is completed.

Start the server as below:

 Now you need to write url in browser as below:
(1) if your tomcat server has port 8088 then write url as


otherwise, if your tomcat server has port 8080 then write url as


then new server window will open as below:

Now, a new open window will open and the project HEERA folder will show on the the server on Applications tables as below:

Now, click on the HEERA and new window will open as below:

Enter name of a person and click on login button.

Then, finally servlet load the name on bowser that you have entered.