• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is this needed? --- pageContext.getOut().flush()

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've seen many example tag classes that have pageContext.getOut().flush();, wrapped in a try/catch, as the first line of doEndTag().
1. What is the purpose of that?
2. From the docs at JspWriter.flush() it seems that this call would forward the flush onto the Response. Would this disallow a tag error from redirecting the user to the error page? (Response.flushBuffer() commits the status and headers, disallowing future redirects in the page, right?)
3. What bad things happen if you don't flush it?

If there is a good explanation of any of this, I'd love to be pointed to some good docs.
Thanks!
[ May 12, 2004: Message edited by: scott p laplante ]
 
scott p laplante
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've found other examples of this, but cannot find any documentation as to why one would want to do this. any ideas?
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) It will cause the output buffer to flush prior to processing the rest of the end tag handler (which is usually what emits any output of the tag in non-body tags).
2) Yes, once committed, headers cannot be written so no redirects are allowed.
3) Can't think of any.
Body tags are different since they have their own buffers... but that, as they say, is another show.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic