• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Robert Gagliardo
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic