code:    public void serveImage(ResourceRequest req, ResourceResponse resp) throws IOException {
        String fn = req.getRenderParameters().getValue("fn");
        String ct = req.getRenderParameters().getValue("ct");
        
        resp.setContentType(ct);
  
        String path = req.getPortletContext().getRealPath(fn);
        File file = new File(path);
        OutputStream os = resp.getPortletOutputStream();
        Files.copy(file.toPath(), os);
        os.flush();
     }
  