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

sendError() - commited

 
Renata fonseca
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the SCWCD book says that sendError() must be called before commiting the response.
But..

I tested it but it didn't throw any exception! WHY?
 
Raji Ram
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Renata fonseca:
the SCWCD book says that sendError() must be called before commiting the response.
But..

I tested it but it didn't throw any exception! WHY?


Hi Renata,
out.println(1); does not commit the response.
You have to write a code to flush.

Hope it is clear.
Good luck!!
 
Renata fonseca
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raji Ram:

I tested it but it didn't throw any exception! WHY?<hr></blockquote>

Hi Renata,
out.println(1); does not commit the response.
You have to write a code to flush.

Hope it is clear.
Good luck!![/QB]


I tried it... But it didn't work yet. No exception was threw... and print "1" in the browser output.
 
Sri Ram
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted this question to MR.Hanumant Deshmukh, see below for his reply...
The idea is if the client receives any data other than the redirect header from the server, you cannot redirect it to another location. Now, servers usually buffer the data that you write using out.print(). So if you print a lot of data to out, it will be sent to sent to the client as soon as the buffer is full. You may not even need out.flush() to "commit" the response. In some cases, if you write very little data, even out.flush() may not immediately send the data (usually it does though). It is implementation dependent.
So, you should not write to the output if you want to redirect the client.
BTW, as per the API, res.sendRedirect() commits the response. I.e. it probably sets a committed flag (no matter whether any of the output has been sent to the client or not).
===================
I'm just a programmer!
 
Raji Ram
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vanniarajan.
[ February 18, 2003: Message edited by: Raji Ram ]
 
Renata fonseca
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic