I use PrimeFaces and need to deliver a dynamic file content (image or PDF), which is read from the file system and is not cashed - neither on the server nor on the file system. I also need to access the HttpSession, as it contains information on which folders the user is entitled to see.
I have the following options:
1.) Up to know I was using the imlementation of BalusC for rendering dynamic image with PrimeFaces:
https://stackoverflow.com/a/12452144/1925356
2.) There is also the option of using PrimeFaces Extensions:
https://www.primefaces.org/showcase-ext/sections/documentviewer/basic.jsf
3.) Finally, one could always write an own HttpServlet and let it read the binary file from the file system and deliver it back to the client.
In all the cases above I could request the HttpSession session, for example in (1) and (2) like this:
(( HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getSession(false)
in the body of the method, which delivers the StreamedContent - and decide whether to return the StreamedContent representing the file or just an "empty" StreamedContent.
I.) Am I wright for cases (1) and (2)
II.) Which of the above approaches (1), (2), (3) is best in terms of performance ?