Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to send the output of a jsp page via email

 
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!
 
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
 
Won't you be my neighbor? - Fred Rogers. tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!