/** * Convert the data to JSON and send it to the client. * * @param req The client request. * @param resp The client response. * @param payload The data to convert to JSON and send. * @throws IOException */ protected void sendResponse( HttpServletRequest req, HttpServletResponse resp, Object payload ) throws IOException { if (payload == null) return; FilterProvider filters = new SimpleFilterProvider().addFilter("BaseEntity",new CanReadFilter()); String json = getObjectMapper(req).filteredWriter(filters).writeValueAsString(payload); log.warning("json::".concat(json)); log.warning("json size::"+json.length()); resp.setContentLength(json.length()); resp.setContentType("application/json"); resp.getWriter().write(json); resp.flushBuffer(); }