how to remove or hide the Http response error using java

I have a REST web service class which i call HttpRequest using curl.I wrote the web service using jersey framework and java in Netbean IDE.If the HttpRequest syntax is correct, the response shows Ok. But When I request the wrong syntax , the response show like this :

< HTTP/1.1 400 Bad Request
< X-Powered-By: Servlet/3.0
< Server: GlassFish Server Open Source Edition 3.0.1
< Content-Type: text/html
< Content-Length: 1049
< Date: Mon, 16 May 2011 01:13:31 GMT
< Connection: close
< GlassFish Server Open Source Edition 3.0.1 - Error report style type="text/css" H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} A {color : black;}HR {color : #525D76;}--> style> HTTP Status 400 -


type Status report
message
descriptionThe request sent by the client was syntactically incorrect ().


GlassFish Server Open Source Edition* Closing connection #0

My question is how to remove or hide the code here in java?Do anyone know if the response is 400 or 403 or 500. If can remove or hide, can I replace something with exception using java ?


You can use the error-page tag (1 per error code), in your application's web.xml to map specific errors to custom error pages. Example (in your web.xml):

<error-page>
 <error-code>400</error-code>
 <location>/myCustomErrorPage.jsp</location>
</error-page>
链接地址: http://www.djcxy.com/p/45616.html

上一篇: 在JAX中映射自定义异常

下一篇: 如何使用java删除或隐藏Http响应错误