Hello, I am generating a simple report using JDBC and formatting the data and displaying it as a jsp file but besides displaying the page, I also would like to be able to email the very same page to someone else. Is there a way to access the contents of the page after it is generated? I do not want to modify the code to write everything onto a file and then email/and or display it. Is there a better way to do it? Any suggestions welcome. thanks
Since the contents of a JSP are written to the HTTP response, the simplest way to trap them is to create a request URL and send it to the web server, then grab the response. Look into the java.net.URLConnection and HttpURLConnection classes. Bill
From another perspective: I've recently done a similar thing, but I've created a subclass from BodyTagSupport. This provides a BodyContent() object that gives you access to the JspWriter buffer (from memory via the getString() method). The BodyContent also offers getReader() method as well. From these classes/methods you can retrieve the entire response being sent to a browser. This has been very sucessful for my puposes.
for your porpoises? [ February 12, 2002: Message edited by: Adam Hardy ]
I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
posted 17 years ago
Just as well it was only a typing error, and not a spelling mistake.
Hello, I am faced with a similar situation. I am assuming that tags are being used since BodyTagSupport is being subclassed. Can someone give an example of how to implement the tag. I am quite new with tags. Thanks, Trish
I have also had success with creating a class that implements HttpServletResponse to wrap the true HttpServletResponse object provided by the container. Most of the calls are passed through (sendRedirect, addHeader, etc) but overriding the getWriter() method (and all the associated methods - flush, close, etc) to work on my own PrintWriter. To obtain the output, create an instance of the Adapter and pass it to RequestDispatcher.include(request, wrappedResponse). I believe you could also do something similar with the 2.3 Filtering API, if you have that available in your container. I have the code, if you'd like it. I think it's too long to post here. Chris
"First Light" Thanks for participating here at the Ranch. However, the name you are using does not comply with the naming convention described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name (not fictitious monikers). Please log in with a new name which meets the requirements. Thanks. Sean
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad: