04.06.2017 Views

servlets_tutorial

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Java Servlets<br />

"\n";<br />

out.println(docType +<br />

"\n" +<br />

"" + title + "\n" +<br />

"\n" +<br />

"" + title + "\n" +<br />

"" + res + "\n" +<br />

"");<br />

}catch (MessagingException mex) {<br />

mex.printStackTrace();<br />

}<br />

}<br />

}<br />

Now let us compile the above servlet and create the following entries in web.xml<br />

....<br />

<br />

SendEmail<br />

SendEmail<br />

<br />

<br />

SendEmail<br />

/SendEmail<br />

<br />

....<br />

Now call this servlet using URL http://localhost:8080/SendEmail which would send an<br />

email to given email ID abcd@gmail.com and would display following response:<br />

Sent message successfully....<br />

Send Email<br />

If you want to send an email to multiple recipients then following methods would be<br />

used to specify multiple email IDs:<br />

void addRecipients(Message.RecipientType type,<br />

97

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!