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

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

 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Sangita Hota
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic