Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please answer these few doubts

 
Rakesh Jhamb
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please just explain me what happens :-
1)after sendError() has been executed and we write to the response.
there is ambiguity in answers given in JWEBPLUS and Study Kit.
2)after forward() has been executed and we write to the response.

3)it is mentioned in Study kit book that setStatus() method does not trigger the error page machinery and just sends the status code directly to the browser, but it is triggering ....
the error page mapped in web.xml for that status code is being displayed.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you call setStatus (it doesn't matter if it's an error or non-error status code), the servlet is still responsible for providing the body of the response to the client.
Now, if the status code is, say, 404, and you'd mapped this to an error page in the deployment descriptor, then this probably explains why your error page is being displayed.
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IllegalStateException will be thrown if continue to write to reponse
after sendError(), sendRedirect(), forward() has being called.
setStatus() will be ignored after the response has been committed.
[ September 23, 2003: Message edited by: chi Lin ]
 
Neeraj Singhal
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi chi
IllegalStateException will be thrown if continue to write to reponse
after sendError(), sendRedirect(), forward() has being called.

When I tried with Tomcat, it DID NOT throw any IllegalStateException if we continue to write to response after sendError(), sendRedirect(), forward() has being called.
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neeraj,
what I meant to say is :
sendError(), sendRedirect(), forward() will throw IllegalStateException if called after response is committed.
regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic