java - HTTPServletResponse status code is not in HTTP response header - Stack Overflow
Basically, that's not how you should use Jersey.
Here's what's happening:
The method executes, and you interact with the ServletResponse and set the status code to 500. But since you don't write any data, the response isn't committed.
Then the method returns a String value. Since Jersey has no way of knowing if you've interacted with the ServletResponse or not, it behaves normally.
A String method that returns implies a 200 response code (void implies 204, etc). Jersey tries to set the response code to the default, ultimately by calling
setStatus(200)on the response instance. Since the response hasn't been committed yet, this isn't a problem, and the response of 500 is changed to 200.The HttpServletResponse is committed and is sent back to the client.
Read full article from java - HTTPServletResponse status code is not in HTTP response header - Stack Overflow
No comments:
Post a Comment