The value of the data
attribute is wrong. It should represent a (relative) HTTP URL, not a local disk file system path. It's namely the webbrowser who has got to download the content individually once it encounters the value during parsing the retrieved HTML output. It's not the webserver who has got to inline the content from its local disk file system somehow during generating the HTML output, as you seemed to think. That's not how HTTP and HTML works.
So, to fix your problem, just make sure that the value of the data
attribute represents a valid HTTP URL. Exactly the one like as you would type in browser's address bar in order to retrieve the content. So, somehow you need to tell your server to return the desired PDF content when a certain URL is been requested.
The easiest way to achieve that is creating a simple file servlet. Here's a kickoff example (obvious error handling such as empty pathinfo, non-existing files, etc omitted for brevity):
@WebServlet("/reports/*")
public class ReportServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String filename = request.getPathInfo().substring(1);
File file = new File(System.getProperty("java.io.tmpdir"), filename);
response.setHeader("Content-Type", getServletContext().getMimetype(filename));
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
Files.copy(file.toPath(), response.getOutputStream());
}
}
This can then be invoked as follows:
<object type="application/pdf" data="#{request.contextPath}/reports/#{bean.pdfPath.name}" height="600" width="900"></object>
See also: