Search code examples
javajspservletshttp-error

jsp get http error description


Is there a way to get the tomcat default description of a HTTP error in a jsp page? I can get the Status code (404, 500, 505), like:

<%=response.getStatus() %>

but I didn't find how to get the description:see the printscreen

Have you any ideas?

Thank you for your help.


Solution

  • If someone is interested I found the answer on stackoverflow : Java library to map HTTP status code to description?

    You will need to download the jar of Appache Commons HttpClient and import it to your jsp page:

    <%@page import="org.apache.commons.httpclient.*"%>
    

    And with the method getStatusText you can get the Http Error description: <%=HttpStatus.getStatusText(response.getStatus())%>.