While
not the "easy" way out, Id suggest using XSL and dynamic XML for
this.
On the
other hand, what you need to do is read in the HTML file in your servlet, parse
it, then spit it out as part of the response. I forget exactly how to read in
the files..but ideally you either want to use a URL to it (incase you want to
access html docs from other sites), or use the getResource() call. You do want
to read in the html into memory, so perhaps a caching setup would be
good.
Let me
ask you this..do these HTML pages "change", in other words, are they supposed to
be dynamic, and thus use JSP to generate the HTML? If so, then you definitely
need to use a URL object to make a url connection to your own server (from
within your own server..seems odd) so that the JSP page is processed as JSP, and
you get the dynamic HTML output of it. Otherwise, if you just read it in via the
getResource() call you'll have your original JSP doc, and not the dynamic output
from it. This wont be what you want.
Keep
in mind, that when a request is made to your servlet and your servlet in turn
makes a request to a JSP page, your doing double-requests..which will decrease
your performance a little bit. If you do not require dynamic HTML pages, then
use a Hashtable (or better yet, a Hashmap if no modifications are to occur to
the html, since Hashmap is not syncronized and thus is much faster at retrieving
objects) to keep the pages in memory. If you have a LOT of them, then perhaps
load only those that are used the most in memory, leaving the other ones on
disk. You could create a simple priority system where by you specify an array of
"filenames" and "load in memory" or "keep on disk" type of priority. Should
require only a few lines of code to do this.
-----Original Message-----
From: McKain, James (DPYUS) [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 15, 2001 10:47 AM
To: [EMAIL PROTECTED]
Subject: printer friendly pagesHello,
I am a begginner reaching deep on this one....I am trying to create a servlet/jsp that takes an incoming html or php file and filters it out for printing. I want the rich-text-only html to be turned into a simple 10 point font printable document. Is there an easy way to do this? I just want to pass an object (the html file) through a method(?) that will shrink the text, and condense data for minimal printer paper usage while preserving the formal (tabs and bullets) of the original.This sounds easy I guess, but I have no clue what I should be typing. help!
