Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getWriter() Vs getOutputStream()

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's legal to use either of them twice in say doGet()


This produces output as SandeepVaid i.e out + out1


However,


This just sends jsp-api.jar to browser. why not both the jar files ?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only send back one response.

For PrintWriter, the entire example is writing to the same response (in fact, both variables are likely pointing to the same object).

For OutputStream, once you've called flush() your response is sent. You're done. Your second flush() call may even be causing an IllegalStateException - check your console.
 
Sandeep Krish
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may not get the illegal state exception always since the containers are using customised writers and Streams.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic