I'm working on an AJAX-enabled JavaScript frontend that makes calls to a Java backend written with Struts. My problem is that when the backend throws an exception, the client still sees a "200 OK" HTTP response code instead of "500 Internal Server Error" like one would expect.
This is tripping me up repeatedly because my 3rd-party client JavaScript library depends on HTTP status codes to determine if something is wrong with an AJAX call, as most modern libraries normally do. The errors pass undetected until my code blows up when it tries to parse what would normally be JSON.
I really want to avoid hacking my client JS library in order to gracefully handle these errors. So then, how can I make Struts give me a 500 status code when there's been an unhandled exception in the backend? Shouldn't this be Struts's default behavior?
Edit: The client-side code is irrelevant in this case. I am needing to fix the server so it sends the appropriate status code when unhandled exceptions happen. Thanks!