This is Paul from the Jersey team:
You must clear the object from your servlet filter, or you can register the ContainerResponseFilter in Jersey, something like:
public class PurgeErrorEntityResponseFilter implements ContainerResponseFilter { @Override public ContainerResponse filter(ContainerRequest request, ContainerResponse response) { if(response.getStatus() == 400) { response.setEntity(null); } return response; } }
and web.xml:
<init-param> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name> <param-value>xyzPurgeErrorEntityResponseFilter</param-value> </init-param>
It worked for me. I have done this:
response.setEntity(StringEscapeUtils.escapeHtml(response.getEntity().toString()));
and he escaped the error message. Thank you Paul!
source share