• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending email from JSP

 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to create a JSP page (contact.jsp) which will have an option of sending email. Code for sending the email will be server-side script. I'm confused about where should I to put logic. Java class or Servlet or another JSP file ? After sending the email system should come back to contact.jsp with status. Really appreciate any ideas.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any type of processing which does not render the view should not be done in a JSP.

The mail generation itself would use the JavaMail API.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don�t try to fire email as soon as user submits the page.

The ideal way is, first insert mail details in database, have one mail daemon that periodically query the database and send mail as per the data exist in database and also log the success or failure status in the database.

The advantage of this way is that, if by any reasons there is problem in email sending routine, you can send emails later on after solving the problem as you already have failed email details in database.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!