com.qindesign.servlet
Class SendMailServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.qindesign.servlet.SendMailServlet
- All Implemented Interfaces:
- Servlet, ServletConfig
public class SendMailServlet
- extends HttpServlet
Example servlet that processes POST requests to mail things. This uses the
mailTo initialization property.
- Version:
- 1.0.4
- Author:
- Shawn Silverman
|
Method Summary |
protected void |
doPost(HttpServletRequest req,
HttpServletResponse resp)
This method will be called when a mail request is posted to this
servlet. |
void |
init()
Checks the "mailTo" initialization parameter for the target email
address. |
SendMailServlet
public SendMailServlet()
init
public void init()
throws ServletException
- Checks the "mailTo" initialization parameter for the target email
address. All emails will be sent to this address.
- Overrides:
init in class GenericServlet
- Throws:
ServletException - if this parameter is not set.
doPost
protected void doPost(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
- This method will be called when a mail request is posted to this
servlet.
Certain request properties are of interest:
from is the sender's email address.
subject will place a subject on the email.
content is the email content.
nextPath tells this servlet where to forward the
request once the mail has been sent. Keep in mind that the
request has the "POST" method, and so nextPath will be
called with a "POST" as well.
- Overrides:
doPost in class HttpServlet
- Throws:
ServletException - if the mailhost is not set, or if there was
an I/O error while sending the email.
IOException
© 2001-2007 Shawn Silverman