File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ignore exception when cannot connect to smtp server

 
protik ahmed
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic