@RequestMapping(value = "/playAudio/{id}") public void playAudio(HttpServletResponse response, @PathVariable(value = "id") int id) { log.debug("in audio streaming, id = {}", id); WallPost post = postService.getPost(id); OutputStream output = null; try { output = response.getOutputStream(); response.setContentType(post.getAudioContentType()); output.write(post.getAudioContent()); output.flush(); } catch (IOException e) { e.printStackTrace(); } finally { try { output.close(); } catch (IOException e) { } } }