/*
 * servlet1.java       4/14/99 Jocelyn Becker
 *
 */

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


/**
 *  
 * This is a simple example of an HTTP Servlet that responds to input
 * parameters such as form input.
 */
public class servlet1 extends HttpServlet
{
    /**
     * Handle the GET and HEAD methods by building a simple web page.
     * The doGet method parses the input parameters and constructs
     * an output page based on the information received from the form.
     */
    public void doGet (
        HttpServletRequest      request,
        HttpServletResponse     response
    ) throws ServletException, IOException
    {
        PrintWriter             out;
        String                  title = "Example Form Response";

        // Set content type and other response header fields first.
        response.setContentType("text/html");

        // Get an output stream.
        out = new java.io.PrintWriter(response.getOutputStream ());

        // Print the HTML, HEAD, and TITLE tags.
        out.println("<HTML><HEAD><TITLE>");
        out.println(title);
        out.println("</TITLE></HEAD><BODY>");
        out.println("<H1>" + title + "</H1>");
        out.println("<P><FONT color=green>This page was generated by a servlet.</FONT></P>");
      
        // Print the query string just for informational purposes.
        String queryString = request.getQueryString();
        out.println("<P>The query string is <CODE>" + queryString + "</CODE>");
        
        // Extract the values of the parameters sent by the form.
        // If a parameter does not exist, getParameter() returns null.
        String companyname = request.getParameter("companyname");
        String numberofpeople = request.getParameter("numberofpeople");
        String companysize = "";
        String hosting = request.getParameter("hosting");
        String design = request.getParameter("design");
        String javadev = request.getParameter("javadev");
        
        // Display the input parameters
        out.println("<P>The values of the parameters sent by the form are:</P>");
        out.println("<BLOCKQUOTE><I>number of people: " + numberofpeople);
        out.println("<BR>company name: " + companyname);
        out.println("<BR>hosting: " + hosting);
        out.println("<BR>design: " + design);
        out.println("<BR>javadev: " + javadev + "</I></BLOCKQUOTE>");
        
        // For the main part of the page, construct
        // a customized message encouraging the user
        // to use our company to help with its web needs.
        
        // Construct an unordered list of the skills needed.
        // First test if any skills are needed.
        // If the user did not select any skills, create a generic message.
        // Otherwise create an unordered list with a bullet item for each skill selected.
        String skillsneeded = "";
        if (( hosting == null) && (design == null) && (javadev == null))
        {
          skillsneeded = " all your web server requirements.";
        }
        else 
        {
            skillsneeded = "<UL>";
            if ((hosting != null) && (hosting.equals("on")))
                skillsneeded +=  "<LI>Web hosting";
            if ((design != null) && (design.equals("on")))
                skillsneeded +=  "<LI>Web page design";
            if ((javadev != null) && (javadev.equals("on")))
                skillsneeded += "<LI>Java servlet and JSP development ";
            skillsneeded = skillsneeded + "</UL>";
        }
        
        // Figure out what size company sent the form.
        // Choices are small, small to medium-size, medium-size and large.
        
        if (numberofpeople == null) 
            numberofpeople = "size unknown";
        else if (numberofpeople == "oneplus")
            companysize = "small ";
        else if (numberofpeople == "tenplus")
            companysize = "small to medium-size ";
        else if (numberofpeople == "hundredplus")
            companysize = "medium-size ";
        else companysize = "large";
        

        // Print a message tailored to the company that sent the form.
       
        out.println("<H3><FONT color=magenta>We would love to help your " + companysize + " company");  
        out.println(" to solve its needs for " + skillsneeded + "</FONT></H3>");
       
        // Print the closing tags in the HTML page and close the output stream.
        out.println("</BODY></HTML>");
        out.close();
   }
   
 
}



 