// com.mindprod.practice.HelloServletWorld.java
// Invoke with http://practice.org:8080/servlet/com.mindprod.practice.HelloServletWorld?firstname=Roedy
// Source code goes in C:\com\mindprod\practice\WEB-INF\src\com\mindprod\practice\HelloServletWorld.java
// Caucho Resin servlet womb will automatically compile it with necessary jars.

package com.mindprod.practice;

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

/**
 * Capture a GET from an Applet
 */
public class HelloServletWorld extends HttpServlet
   {
   protected void doGet( HttpServletRequest req,
                         HttpServletResponse res)
   throws ServletException, IOException
   {
      res.setContentType( "text/html" );
      String firstname = req.getParameter( "firstname" );
      if ( firstname == null )
         {
         firstname = "unknown";
         }
      PrintWriter out = res.getWriter();
      out.println("<html><body>Hello, " + firstname + ". Welcome to Servlet World! </body></html>");
      out.close();
   }

   public String getServletInfo()
      {
      return "HelloServletWorld 1.0 by Roedy Green, echoes firstname parameter.";
      }
   }