Example #1
0
 public void setData(Object data) {
   if (data == null) {
     response.setStatus(HttpStatus.NO_CONTENT);
   } else if (data instanceof String) {
     String content = (String) data;
     response.setContentType("text/plain");
     response.setCharacterEncoding("utf-8");
     response.setContentLength(content.getBytes().length);
   } else {
     try {
       service.serialize(data, this.request, this.response);
     } catch (HttpException e) {
       setStatus(e.getStatus(), e.getMessage());
     } catch (IOException e) {
       setStatus(HttpStatus.INTERNAL_SERVER_ERROR, "Serialization failed");
     }
   }
 }
Example #2
0
 public void setContentLength(int len) {
   response.setContentLength(len);
 }