John Hawkins wrote:

> Does anyone know a good way of capturing the output generated by a JSP
> so that it can be written to a file ? (I basically want to use .JSP's
> as templates to generate a static HTML site). What I'd like to do is
> have a wrapper JSP which does 2 things, 1. Redirects out so that it is
> writing to a file rather than returning stuff to the server ...2.
> jsp:include's another JSP file whose output it want's to capture. I
> can sort of see a way to do this by providing my own JSPWriter, but
> does anyone have any better ideas or any realexperience of doing
> something like this ? I guess the other way is to use something like
> JSPExecutor .... Any ideas greatfully received, John.

I've dealt with this issue in a totally different manner to generate
static HTML pages from a servlet app (but it would work for JSP just as
well).  The idea is to write a Java application that uses a
URLConnection to retrieve each page, and then writes the output (without
the headers) to a file of the same name as the page.  You could either
enumerate the individual URLs in arguments to the program, or you could
make it smart enough to parse the pages and follow the links (just like
search engine spiders do).  The nice thing about this approach is that
it requires no fancy modifications at the server end.

There's examples of using URLConnection, among other places, in
the Java Language Tutorial (http://java.sun.com/docs/books/tutorial).

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to