A Setup Test

The Servlet

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public class test2 extends HttpServlet{
 
        public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException{
             String the_name = request.getParameter("whoisit");
                PrintWriter out = response.getWriter();
                out.println("<html>");
                out.println("<body>");
                out.println("<h1>Hi "+the_name+"</h1>");
                out.println("</body>");
                out.println("</html>"); 
        }
}


web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0">
  <servlet>
        <servlet-name>test2</servlet-name>
        <servlet-class>test2</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>test2</servlet-name>
        <url-pattern>/test2</url-pattern>
    </servlet-mapping>
</web-app>


The calling HTML

<html>
<body>
<form name="loginForm" method="get" action="http://localhost:8080/courseexamples/test2">
    Enter Your Name: <input type="text" name="whoisit"/> <br/>
    <input type="submit" value="Tell Me" />
</form>
</body>
</html>