When I try to request for a non existent resource using a GET request for –
http://localhost:8080/jackrabbit/server/default/jcr:root/user/abc/article/article-1.0.json
I am expecting a 404 response but in JSON format. But instead I get an html response –
<html><head><title>Apache Tomcat/6.0.32 - Error report</title>...</body></html>
How can I make sure that this content is returned in JSON format instead of HTML format. I have specified the following in web.xml but that did not help –
<mime-mapping>
<extension>json</extension>
<mime-type>application/json</mime-type>
</mime-mapping>
You should configure a 404 error page that sets the proper content type and outputs JSON.
Where
/notFoundJSONis mapped to a servlet that usesresponse.setContentType(..)and writes JSON to theresponse.getWriter()