private void setErrorPageContentType(Response response, String location, Context context) { if (response.getContentType() == null && location != null) { String str = location.substring(location.lastIndexOf('.') + 1); str = context.findMimeMapping(str.toLowerCase(Locale.ENGLISH)); if(str != null) ((ServletResponse) response).setContentType(str); } }