How does one dynamically obtain a JspWriter using a desired character
encoding?

My problem specifically is that I have a JSP page which can dynamically
select XSLT stylesheets to apply to XML.  XSLT stylesheets call out their
output MIME type *and* character encoding in one of their tags.  One then
typically includes HTML META tags that match this or, in the case of XML
output, XSLT will declare the character encoding in the XML header of the
output.

With servlets, I simply do response.getOutputStream() and let the XSLT
library create the correct Writer.  With JSP, I get only a JspWriter, whose
character encoding I don't seem to have dynamic control over, i.e. I can
declare it in a page declaration, but I can't say "give me a JSP writer with
an encoding of myXSLT.getCharEncoding()".  How is this intended to work in
reality?  DO NOT tell me I have to have 'n' JSP pages for all of my intended
character encodings (I only intend one but those using this stuff will
declare any JVM-valid character encoding in their XSLT).  Also, DO NOT tell
me that I have to reparse my XSLT output to remove this declaration and
dynamically replace it with that specified by JSP.

Along these lines, does JSP automatically HTML/XML escape characters outside
the bounds of the target character encoding???  For instance, if outputting
to Latin-1 are Japanese Unicode characters automatically escaped ala Ɖ?
XSLT does this, of course.

Also, why can't I use an OutputStream from JSP?  What if I want to
dynamically create a GIF or a JPEG?  In other words, no, such output formats
won't leverage JSP's template nature, but JSP could still be an attractive
way of getting a new dynamically generated servlet which called utilities
for such.  I am mainly trying to understand *intent* on this matter, but I
really *need* to understand how to synchronize character encodings between
dynamically selected XSLT pages and the JspWriter.

What I am doing now, but haven't really tested is simply setting the
Content-Type header to match my XSLT's MIME and encoding and then using the
JspWriter (for the first time, i.e. I don't even have blank lines before
this) to dump the XSLT output.  I have *zero* confidence that JSP engines
will parse this ContentType and use the encoding I really need them to use
when creating the JspWriter.

--
Jess Holle
[EMAIL PROTECTED]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to