package client_server;

/**
 * EmailProcessor processes a request from a web page.  It responds to the
 * request by sending back a web page listing the name and email address.
**/
import java.io.*;

public class EmailProcessor extends WebRequestProcessor
{
	public void process (Request request, Response response)
	{
		// Get the request parameters, name and email.
		String name = request.getParameter ("name");
		String email = request.getParameter ("email");

		// Get a PrintWriter object and respond to the request.
		PrintWriter out = response.getWriter ();
		Page.createHeader (out, "Email Address");
		out.println ("<h3>Hello.</h3>");	
		out.println ("<h3>" + name+ "</h3>");
		out.println ("<h3>Your email address is " + email + "</h3>");
		Page.createFooter (out);				
	}
}

// Class with static method that add standard lines to the html output page.
class Page
{
	public static void createHeader (PrintWriter out, String title)
	{
		out.println ("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>");
		out.println ("<html>");
		out.println ("<head>");
		out.println ("<title>" + title + "</title>");
		out.println ("</head>");
		out.println ("<body>");
	} // createHeader
	
	public static void createFooter (PrintWriter out){out.println ("</body></html>");} 
	
	
} // class Page
