Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ignore exception when cannot connect to smtp server

 
protik ahmed
Greenhorn
Posts: 15
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic