Forums Register Login

Diff b/w setStatus(int) and sendError(int)

+Pie Number of slices to send: Send
HI,

Can anyone please explain the difference b/w setStatus(int) and sendError(int) methods of HttpServletResponse.

Thankz n Regards,
Puneet

(SCJP 1.4 , SCBCD)
+Pie Number of slices to send: Send
public void setStatus(int sc)Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there is an error, and the caller wishes to invoke an error-page defined in the web application, the sendError method should be used instead.

public void sendError(int sc)
throws java.io.IOException Sends an error response to the client using the specified status code and clearing the buffer.
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
Normally trees don't drive trucks. Does this tiny ad have a license?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 510 times.
Similar Threads
setStatus() and sendError()
Please answer these few doubts
sendError(int) vs setStatus(int)
setStatus(),sendError() & IllegalStateException
setStatus Method of HttpServletResponse
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:32:05.