Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to send the output of a jsp page via email  RSS feed

 
ilkay benian
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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!
 
Joe Pardi
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!