import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * ApplicationServlet is a small example of a servlet that can also
 * be called as an application.
 *
 * @author mitch fincher, mitch[at]fincher[dot]org
 */

////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
public class ApplicationServlet extends HttpServlet {
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
public void doGet (HttpServletRequest req, HttpServletResponse res)
////////////////////////////////////////////////////////////////
       throws ServletException, IOException
  {
    res.setContentType("text/html");
    ServletOutputStream sout = res.getOutputStream();
    PrintStream out = new PrintStream(sout);
    String name = req.getParameter("name");
    doMyFunction(out,name);
  }
  
////////////////////////////////////////////////////////////////
public void doMyFunction(PrintStream out, String Name)
////////////////////////////////////////////////////////////////
  {
    out.println("<html><body>");
    out.println("<h1>Howdy  " + Name + "</h1>");
    out.println("</body></html>");
  }

////////////////////////////////////////////////////////////////
    public String getServletInfo() {
////////////////////////////////////////////////////////////////
	return "Create a page that says <i>Hello World</i> and send it back";
    }

////////////////////////////////////////////////////////////////
public static void main(String argv[])
////////////////////////////////////////////////////////////////
  {
     ApplicationServlet app = new ApplicationServlet();

     app.doMyFunction(System.out, "Main Dude");
  } // function main()

} // class ApplicationServlet
