I actually have implemented a hack to do this in one former project. It was a wizard like application and the last jsp page presented a summary view. When the user accepted, the content of the page was send to him/her via e-mail. So the following bits of code work but I think it's really a hack, it was just needed as a temp solution before we had PDF generation in place.
In the Action class, the following code is used to capture the output of a "jsp execution" RequestDispatcher rd = getServlet().getServletContext().getRequestDispatcher("my.jsp"); GrabberResponse resp = new GrabberResponse(); rd.forward(request, resp); resp.getString(); The trick is to implement a custom HttpServletReponse class, with just the minimum required methods implemented to make it work and capture the output. In the listing below, I have just left the useful methods, all the other methods required by the interface are empty or returning some dummy value (null, 0, ...). Additionally you can put a log statement in each method so you can trace what you need to implement to make it work. public class GrabberResponse implements HttpServletResponse { private ServletOutputStream os; private PrintWriter pw; public GrabberResponse() { os = new ServletOutputStream(); pw = new PrintWriter(os); } public String getString() { return os.getString(); } public javax.servlet.ServletOutputStream getOutputStream() throws IOException { return os; } public PrintWriter getWriter() throws IOException { return pw; } } You also need a customer ServletOutputStream associated with it. Here, as it extends an existing class, all the methods not listed use the parent's implementation. You can also re-implement the methods to add a log statement if required and then simply call super's implementation. public class ServletOutputStream extends javax.servlet.ServletOutputStream { private ByteArrayOutputStream os; public ServletOutputStream() { os = new ByteArrayOutputStream(); } public String getString() { return os.toString(); } /** * This is the only method that is really delegated to the enclosed output stream. */ public void write(int b) throws IOException { os.write(b); } } Eric. > -----Original Message----- > From: Joe Hertz [mailto:[EMAIL PROTECTED] > Sent: Saturday, January 24, 2004 3:47 AM > To: [EMAIL PROTECTED] > Subject: Re: JSP to static html... > > I had a requirement like this once, but the reports were generated by > Seagate > Crystal. It generated the static HTML. JSP seems like the wrong tool to be > using here. > > I would think (speaking out of my hat here) if the report itself was a JSP > page what you MAY be able to do is something like, in your action, making > an > HTTP request yourself to the JSP, receive the HTML that gets generated in > response into a text buffer, save it some place, and then send the user to > it. If he pushes the button, you have an HTML file you can send him to. > > It's a complete and utter hack, but hey. > > > > ----- Original Message ----- > From: "Jacob Wilson" > To: "Struts Users Mailing List" > Sent: Friday, January 23, 2004 12:30 PM > Subject: JSP to static html... > > > > Hi All... > > > > I have a specific requirement in my project... I want to convert the > > JSP > pages to static html pages and save them in a local directory... How do I > achieve this functionality??? Any suggestions appreciated. > > > > Thanks much. > > > > -Jacob > > > > > > --------------------------------- > > Do you Yahoo!? > > Yahoo! SiteBuilder - Free web site building tool. Try it! > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------- > Do you Yahoo!? > Yahoo! SiteBuilder - Free web site building tool. Try it! > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]