• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to send the output of a jsp page via email

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,
I want to capture the rendered html output of a jsp page and send it via email. I found two methods to do it but each had problems. I know there are people who already do it but I just don't know how they overcame these problems!
The first method is to open a url connection and get the input stream from it and read the ouput. I tested it and it worked for external urls perfectly! If I try to connect to the a jsp page on the same server, it just hangs! I guess it waits for the current jsp page to complete and ends up with a dead lock! Is there a solution to this?
The second method is to implement a custom HttpServletResponse implementation and use it in getRequestDispatcher(...).forward. I tested it on a tomcat server running on a windows system and it worked ok. But the Iplanet server just rejected the custom implementation of HttpServletResponse! The error message is: servlet.NSRequestDispatcher.msg_invalidResClass.
Any ideas, or a working code would be highly appreciated!
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way to do it is via a custom tag.
Write a custom tag that sends the body of the tag as the email. Then use a <jsp:include page="yourPage.jsp"/> as the body of the custom tag. By doing this, the HTML of yourPage.jsp is used as the body of the custom tag. In the tag handler for the custom tag, simply send the HTML as an email.
A few tag libraries offer an email tag that can probably be used to accomplish this.
Jakarta: http://jakarta.apache.org/taglibs/doc/mailer-doc/intro.html
dotJ: http://www.dotjonline.com
Coldtags: http://www.servletsuite.com/servlets/sendmail.htm
- Joe
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic