• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Sending email from JSP

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic