Take a look at the documentation for
sendError() and
setStatus() Basically, setStatus() is used to set non-error codes while sendError() is used for 4xx and 5xx set of statuses.
Also, sendError() will set the error handling/ forwarding mechanism into motion ( the error pages defined etc ) while setStatus() will not.
By the way, your code uses an instance of the HttpServletResponse to get the contants for the status codes. This is against convention.
You should use the class name to access static members ( variables and methods ); like so: