Re: SendMailServlet example & server setup ?
- From: "Dado" <mario_zupan@xxxxxxx>
- Date: Sat, 24 Jun 2006 19:12:25 +0200
"Chris Smith" <cdsmith@xxxxxxx> je napisao u poruci interesnoj
grupi:MPG.1f0705c462b866a19896f3@xxxxxxxxxxxxxxxxxxx
Dado <mario_zupan@xxxxxxx> 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
I put:
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session" mail.smtp.host="mail.iskon.hr" />
inside
</Host>
</Engine>
tags
as I find on Net and restart Tomcat. Then I noticed that tomcat log gives
me:
2006.06.24 12:45:10 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
2006.06.24 12:45:10 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
2006.06.24 12:46:11 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionDestroyed('57DDD22BA86E9B5929E4F9B6FC11343E')
2006.06.24 13:45:54 org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:396)
at SendMailServlet.init(SendMailServlet.java:25)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130
....
line 25 is
super.init(config);
in SendMailServlet.
What I'm doing wrong ?
.
- Follow-Ups:
- Re: SendMailServlet example & server setup ?
- From: Juha Laiho
- Re: SendMailServlet example & server setup ?
- References:
- SendMailServlet example & server setup ?
- From: Dado
- Re: SendMailServlet example & server setup ?
- From: Chris Smith
- SendMailServlet example & server setup ?
- Prev by Date: Re: SendMailServlet example & server setup ?
- Next by Date: classfile has wrong name WRT package?
- Previous by thread: Re: SendMailServlet example & server setup ?
- Next by thread: Re: SendMailServlet example & server setup ?
- Index(es):
Relevant Pages
|