//default value for mail server address, in case the user //doesn't provide one private final static String DEFAULT_SERVER = "mail.attbi.com";
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
String smtpServ = DEFAULT_SERVER;
String from = "java2s@yourserver.com";
String to = "yourname@yourserver.com";
String subject = "subject line";
String emailContent = "emailContent";
response.setContentType("text/Html"); java.io.PrintWriter out = response.getWriter(); out .println("<html><head><title>Email message sender</title></head><body>");
try {
sendMessage(smtpServ, to, from, subject, emailContent);
} catch (Exception e) {
throw new ServletException(e.getMessage());
}
out.println("<h2>The message was sent sUCcessfully</h2>");
//populate the 'Properties' object with the mail //server address, so that the default 'session' //instance can use it. properties.put("mail.smtp.host", smtpServer);