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?
Retrieveing status code from a response in java
1.4k views Asked by Sakthivel At
2
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)