/** 
 * This program is an example from the book "Internet 
 * programming with Java" by Svetlin Nakov. It is freeware. 
 * For more information: http://www.nakov.com/books/inetjava/ 
 */ 
import java.io.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
 
public class HelloServlet extends HttpServlet { 
    public void doGet (HttpServletRequest aRequest, 
        HttpServletResponse aResponse) 
    throws ServletException, IOException { 
        aResponse.setContentType("text/html"); 
        ServletOutputStream out = aResponse.getOutputStream(); 
        String userName = aRequest.getParameter("user_name"); 
        out.println("<html>"); 
        out.println("<head>"); 
        out.println("\t<title>Hello Servlet</title>"); 
        out.println("</head>"); 
        out.println("<body>"); 
        out.println("\t<h1>Hello, " + userName + "</h1>"); 
        out.println("</body></html>"); 
    } 
}
Back to Internet Programming with Java books's web site