This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Please answer these few doubts 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 » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Please answer these few doubts" Watch "Please answer these few doubts" New topic
Author

Please answer these few doubts

Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
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.


SCJP2, SCWCD
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
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.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
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 ]

not so smart guy still curious to learn new stuff every now and then
Neeraj Singhal
Ranch Hand

Joined: Aug 13, 2000
Posts: 49
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

Joined: Aug 24, 2001
Posts: 348
Neeraj,
what I meant to say is :
sendError(), sendRedirect(), forward() will throw IllegalStateException if called after response is committed.
regards
 
 
subject: Please answer these few doubts
 
Similar Threads
ERROR: Cannot forward. The response has already been committed.
Response Filtering Suggestions
Diff b/w setStatus(int) and sendError(int)
Generic Servlet vs HttpServlet
For all SCWCD guys : Doubts