*
The moose likes Servlets and the fly likes The correct way of writing data back to the user is... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "The correct way of writing data back to the user is..." Watch "The correct way of writing data back to the user is..." New topic
Author

The correct way of writing data back to the user is...

Robert Gagliardo
Greenhorn

Joined: Nov 15, 2001
Posts: 24
using the response.getWriter() method to print text, and finally calling response.flushBuffer() if response.isCommitted() is false?
using the response.getOutputStream() method to print data, and finally calling response.flushBuffer() if response.isCommitted() is false?
thanks
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Um, sounds like an homework question question, but my take on the whole thing is 1) I've never called response.flushBuffer(), but the guy next to be has (once) and 2) Writer or output stream depend on whether you are sending text or binary data.
Also, I rarely, if ever, send data from a Servlet so I haven't used isCommitted either...
So after all these details, I would answer 'neither', since it doesn't fit in the way I do things.
Dave.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
People typically use flushBuffer to make sure the client browser gets some content while a time consuming process is going on - so they don't think the whole thing has died while your database grinds away.
Bill
 
 
subject: The correct way of writing data back to the user is...
 
Similar Threads
mock question
response.sendRedirect() behaviour
IllegalStateException
RequestDispatcher and flushBuffer
RequestDispatcher - Response.isCommitted()