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?
2 Answers
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_OKfor success (200)HttpServletResponse.SC_BAD_REQUESTfor indicating a bad request (400)