wood burning stoves 2.0*
The moose likes Struts and the fly likes ignore exception when cannot connect to smtp server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ignore exception when cannot connect to smtp server" Watch "ignore exception when cannot connect to smtp server" New topic
Author

ignore exception when cannot connect to smtp server

protik ahmed
Greenhorn

Joined: Mar 21, 2010
Posts: 15
hi, I am doing a confirmation email system, basically, at a push of a button on my jsp page, data is sent to the action class and among other things an object is loaded to send an email. There are times when I will not be able to connec to the smtp server, I wish to allow the website to fully function when this happens. Currently, when I try to press that button, the page gives me an exception error
ignore exception javax.servlet.servletexception: javax.mail.messagingexception: unknown smtp host smtp.gmail.com; nested exception is..

When the smtp server is connected to and email is sent, the browser loads to home page. WHen it doesn't work, it gives that error message on the page. Is there a way for it to just load the home page instead of loading the exception message?
Kabron Kline
Greenhorn

Joined: Aug 07, 2009
Posts: 20
You need to add in some exception handling (i.e. try/catch). Could you post the action class that handles the form and initiates the email communication?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

There's no need to post the code, just wrap it in a try/catch. Alternatively, you could use Struts' declarative exception handling, but in this case I'd recommend against it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ignore exception when cannot connect to smtp server
 
Similar Threads
JavaMail, SMTP error
Object Error when attempting test email in IE6
Problem in sending test mail and setup mail server
JavaMail response -1 from Server : {
com.sun.mail.smtp.SMTPSendFailedException: 451 4.7.1 Please try again later