Setting the response status with its own statement is good enough. It doesn’t look too ugly and is pretty straightforward:
response.status = 404;
I’ve used this successfully myself and have seen others do it this way too. Since it’s just a setter, you can also do other stuff after setting the status. Whichever status you set last will be what the HttpServletResponse uses when it actually sends the response back to the client.