jsp get http error description

时间:2015-11-12 10:43:27

标签: java jsp servlets http-error

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.

1 个答案:

答案 0 :(得分:3)

如果有人有兴趣,我在stackoverflow上找到答案: Java library to map HTTP status code to description?

您需要下载jar Appache Commons HttpClient 并将其导入您的jsp页面:

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

使用方法getStatusText,您可以获得Http Error描述: <%=HttpStatus.getStatusText(response.getStatus())%>