/** *****************************************************************
ChooseAbs.java ICECCS 2001 Abstract choice
@author Jeff Offutt
@version 3.0 (01/26/01)
This version expects the to address to be sent over as a parameter
from the HTML. It's stored in a hidden field in the HTML file.
This is more flexible: the addressee can be controlled from the
server side.
********************************************************************* */
// Import Servlet Libraries
import javax.servlet.*;
import javax.servlet.http.*;
// Import Java Libraries
import java.io.*;
import java.util.*;
import java.lang.*;
// Import SMTP Class
import sun.net.smtp.SmtpClient;
// ChooseAbs class
//
// CONSTRUCTOR: no constructor specified (default)
//
// **************** PUBLIC OPERATIONS *********************************
// void doPost () --> Main method for gathering data and sending email
// void doGet () --> Not implemented.
// void getParameters() --> Copies data into a StringBuffer.
// Puts in global String message
// boolean SendMail () --> Sends the message through email
// void PrintHead () --> Prints the head of an HTML page
//***********************************************************************
//
// The possible IOException on the PrintWriter is thrown up.
public class ChooseAbs extends HttpServlet
{
String msgFrom, msgTo, msgSubject;
/** *****************************************************
* Overrides HttpServlet's doPost().
********************************************************* */
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
String message;
res.setContentType ("TEXT/HTML");
PrintWriter out = res.getWriter ();
message = getParameters (req);
PrintHead (out);
if (!sendMail (message))
{
out.println ("An error occurred while attempting to access the mail server.");
return;
}
// Send ack
out.println ("Your selections have been submitted.
");
out.println ("Thank you!
");
out.println ("Sten and Jeff");
out.println ("