Code example for HttpResponse

Methods: setEntity, setStatusCode

0
                NStringEntity entity = new NStringEntity(
                        "<html><body><h1>File" + file.getPath() +
                        " not found</h1></body></html>", 
                        "UTF-8"); 
                entity.setContentType("text/html; charset=UTF-8");
                response.setEntity(entity);
            } else if (!file.canRead() || file.isDirectory()) {
                response.setStatusCode(HttpStatus.SC_FORBIDDEN);
                NStringEntity entity = new NStringEntity(
                        "<html><body><h1>Access denied</h1></body></html>", 
                        "UTF-8"); 
                entity.setContentType("text/html; charset=UTF-8");
                response.setEntity(entity);
            } else { 
                response.setStatusCode(HttpStatus.SC_OK);
                NFileEntity entity = new NFileEntity(file, "text/html", useFileChannels);
                response.setEntity(entity);
            } 
        } 
 
    }