Please send questions to st10@humboldt.edu .

/**
 * st10PostOrder.java
 *
 * from: p. 170, Gittleman, "Internet Applications with the Java 2
 * Platform"
 *
 * "echoes the user's [sundae] order made in a POST request"
 * 
 * modified by: Sharon Tuttle
 * last modified: 5-7-01
 **/

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

public class st10PostOrder extends HttpServlet
{
	// no doGet() this time? Interesting... 

	// "echoes the user's [sundae] order made in a POST request"
	public void doPost (HttpServletRequest req, HttpServletResponse resp)
			   throws ServletException, IOException
	{
		// various parameter values
		String 		nameVal, passwdVal, flavorVal, placeVal;
		String		toppingVals[];

		PrintWriter 	out;		// text of response?

		resp.setContentType("text/html");
		out = resp.getWriter();

		nameVal = req.getParameter("name");

		// OK, we don't do anything with this here.
		// (but we COULD... 8-) )
		passwdVal = req.getParameter("password");

		// here's beginning of response to user
		out.println("<html>");
		out.println("<head><title>Ice Cream Servlet</title></head>");
		out.println("<body><h1><strong>Hi " + nameVal);
		out.println("</strong></h1></body>");		

		// what flavor was requested?
		flavorVal = req.getParameter("flavor");
		out.println("Got your order for " + flavorVal + " ice cream<br>");
	
		// what toppings were requested?
		toppingVals = req.getParameterValues("toppings");
	
		if (toppingVals == null)
		{
			out.println("with no toppings");
		}
		else
		{
			out.println("with <ul>");
			for (int i=0; i < toppingVals.length; i++)
			{
				out.println("<li>" + toppingVals[i]);
			}
			out.println("</ul>");
		}

		// and where do they want it?
		placeVal = req.getParameter("place");
		if (placeVal.equals("Eat here"))
		{
			out.println("to eat here.");
		}
		else
		{
			out.println("to go.");
		}

		out.println("</h3></body></html>");
		out.close();
	}
}