FileDocCategorySizeDatePackage
EmailBeanServlet.javaAPI DocExample1288Sat Feb 21 15:06:08 GMT 2004com.jspservletcookbook

EmailBeanServlet

public class EmailBeanServlet extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

    
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    out.println(
    "<html><head><title>Email message sender</title></head><body>");
    
    EmailBean emailer = new EmailBean();

    emailer.setSubject("This is not spam!");

    emailer.setContent("Please call ASAP.");    
	
	emailer.setTo("myfriend@yahoo.com");
	emailer.setFrom("author@jspservletcookbook.com");
	emailer.setSmtpHost("smtp.comcast.net");

	try{
        emailer.sendMessage();
	} catch (Exception e) {throw new ServletException(e);}
    
    out.println("</body></html>");
    

public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

		  
		      doGet(request, response);