Well, the alternative is chunked transfer-coding (which can be used on
either the request or response payloads). This is completely defined by HTTP
1.1, and _must_ be accepted in both directions by HTTP 1.1 compliant apps,
so if you send it to a recent IE browser it should know what to do with it.
I assume. :-)

In the context of servlet engines it doesn't make sense for a servlet to be
aware that a _request_ was transfer-coded, whether chunked or anything else.
The HTTP layer should handle this transparently. If it doesn't then it will
probably choke before your servlet ever gets a chance at it (this is what
should happen anyway).

Going in the other direction one can only that the servlet engine/HTTP
server combo will pick up on the fact that, at the instant that it must
commit the response, it doesn't have a content-length, and will therefore
switch over to chunked transfer coding, thereby keeping the connection open
_and_ allowing you not to worry about calculating an overall content-length.

I see from mailing lists that the Tomcat people were talking about chunked
transfer coding for Tomcat 3.2/3.3 a year or more ago - do they have it
properly implemented in 4.0 - I don't know. Worth checking out.

If all else fails I'd suggest that your servlet do all the work itself, but
my gut feeling is that if the servlet engine doesn't do chunked transfer
coding anyway, it's hardly going to properly react to the fact that your
servlet is doing it itself - it'll probably close the connection on you
anyway after committing the first buffer.

Hope that helps.

Regards,
AHS

> -----Original Message-----
> From: Brian O'Kelley [mailto:[EMAIL PROTECTED]
> Sent: April 15, 2002 7:25 PM
> To: [EMAIL PROTECTED]
> Subject: Omitting content length
>
>
> Ignore the question below - it works (if anyone needs SAX example, this
> is decent).
>
> It looks like what is happening is that I was writing this directly to a
> servlet's outputstream, so I never set the content length header. This
> made IE puke, although Lynx caught it ok. I've read through the threads
> about how IE handles content length header and requests the document
> twice.
>
> Is there any alternative to writing to a byte array to calculate the
> length before rewriting to the servlet's output stream? I'd like to
> avoid the memory consequences.
>
> Thanks,
> Brian
>
>
>
> -----Original Message-----
> From: Brian O'Kelley [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 15, 2002 5:28 PM
> To: [EMAIL PROTECTED]
> Subject: FOP and SAX
>
>
> I'm trying to take an XML document, combine it with an XSL stylesheet,
> and spit it to PDF using SAX events, and I'm having trouble finding an
> example that works.
>
> Here's my code (using Fop 0.20.3):
>
>         TransformerHandler tHandler = XSLTranslateFactory.
>                 getHandler("FopInput.xsl") ; // gets TransformerHandler
> from this file
>         Driver fopDriver = new Driver() ;
>         fopDriver.setRenderer(Driver.RENDER_PDF) ;
>         fopDriver.setOutputStream(out) ;
>         ContentHandler cHandler = driver.getContentHandler() ;
>
>         XMLReader reader = XMLReaderFactory.createXMLReader() ;
>         reader.setContentHandler(tHandler) ;
>
> reader.setProperty("http://xml.org/sax/properties/lexical-handler";,
>                 tHandler) ;
>         tHandler.setResult(new SAXResult(cHandler)) ;
>         reader.parse(source) ;
>
> Any ideas?
>
> Thanks,
> Brian
>
>

Reply via email to