Re: SendMailServlet example & server setup ?
"Dado" <mario_zupan@inet.hr> said:
"Juha Laiho" <Juha.Laiho@iki.fi> je napisao u poruci interesnoj
grupi:e7lvdk$i49$5@ichaos2.ichaos-int...
"Dado" <mario_zupan@inet.hr> said:
"Chris Smith" <cdsmith@twu.net> je napisao u poruci interesnoj
grupi:MPG.1f0705c462b866a19896f3@news.altopia.net...
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");
}
Your code is looking for servlet init parameter smtpServer.
I put:
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session" mail.smtp.host="mail.iskon.hr" />
inside
</Host>
</Engine>
And you're setting something completely else. Please do set the
servlet init parameter smtpServer (this setting goes in web.xml).
So if I understand correctly
Sorry to be blunt, but you're not. You're heavily mixing two ways of
doing things, and the ends are not meeting.
I need to put
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session" mail.smtp.host="mail.iskon.hr" />
into web.xml (of web application)
and
<Resource name="mail/testMail"
auth="Container"
type="javax.mail.Session"
mail.smtp.host="mail.iskon.hr"
mail.smtp.port="25"
mail.transport.protocol="smtp"
mail.smtp.auth="true"
mail.smtp.user="login"
password="password"/>
These look like you're setting up the javax.mail system as a subsystem
of your server. Yes, you can do it this way as well, and this isn't
necessarily a bad idea. However, the mapping of server resource to the
application (the web.xml part here) is not correct, and your application
isn't even trying to access this (you'd need to look up this resource
using JNDI calls, and then just use the retrieved mail session).
Instead, your application is trying to do a full javax.mail subsystem
setup by itself (yes, you can do it that way as well, and then the above
web.xml and server.xml blocks are not needed), but is missing a servlet
init parameter (from web.xml) which the code expects to use.
Decide which way you're going to do it -- a server resource used via
JNDI lookup from the application, or an application-private resource
fully initialised within the application. In the former case it could
be that you're not getting as complete control of the javax.mail
subsystem as with the latter, but most possibly the latter will
involve more code, and is less efficient and elegant than the former.
The former, however, will require you to read up and understand the JNDI
parts of Tomcat documentation from both server configuration and
application developer point-of-view.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)