Reputation: 1
How to retrieve a response code for an error page? For successful page I am using getresponsecode
method. But for an error page, which method I have to use to get a status code of a response of web application?
Upvotes: 0
Views: 1708
Reputation: 2288
httpServletResponse.getStatus()
will give you an int value which represents the status code.
Open HttpServletResponse
class an you ll find the list of the possible status codes
Upvotes: 1
Reputation: 417412
HttpServletResponse.getStatus()
is the one you're looking for. It is not just for error pages, it is for every servlet responses.
The HttpServletResponse
class contains constants for the possible values, e.g.
HttpServletResponse.SC_OK
for success (200)HttpServletResponse.SC_BAD_REQUEST
for indicating a bad request (400)Upvotes: 2