dcsimg
Streaming Output of StringTemplate to HttpServletResponse.getWriter()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, January 28, 2004 03:32 AM

I would expect to find something like pageStringTemplate.write(response.getWriter()) the real code is: public void Page.generate(PrintWriter pageOut) { ... // Make a buffer big enough for the whole output page (reuse buffer) StreamBuffer out = getNewStreamBuffer(); // write page to stream buffer generatePage(out); // write stream buffer to servlet output pageOut.print(out.toString()); ... So you are streaming the template into a buffer and then write this buffer into the output stream. I   More>>

I would expect to find something like

pageStringTemplate.write(response.getWriter())



the real code is:




public void Page.generate(PrintWriter pageOut) {

...



// Make a buffer big enough for the whole output page
(reuse buffer)

StreamBuffer out = getNewStreamBuffer();



// write page to stream buffer

generatePage(out);



// write stream buffer to servlet output

pageOut.print(out.toString());

...




So you are streaming the template into a buffer and then write this buffer into the output stream. I would not rate this as a 'real' problem, because the generation is expected to be very fast. It is just unexpected. I can not see the reason for it.



regards,



Manfred

   <<Less

Re: Streaming Output of StringTemplate to HttpServletResponse.getWriter()

Posted By:   Terence_Parr  
Posted On:   Friday, February 6, 2004 03:25 PM

Yeah, it's pretty inefficient, but I didn't change as server seemed very fast. Better to stream as you say.


Terence

About | Sitemap | Contact