File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Head First Android this week in the Android 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

ignore exception when cannot connect to smtp server

protik ahmed

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; 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

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

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:
subject: ignore exception when cannot connect to smtp server
jQuery in Action, 3rd edition