I'm using jsf 2.2 Primefaces 6.0 and i already implemented a solution to download an images from the ressources file inside the application and it works fine but when i try to download from the outside an error message will appear.I need help to can download from the outside of the application:
Here the error message :
Context Path:/gestion-remboursement-web Servlet Path:/pages/listDemandes.jsf Path Info:null Query String:null Stack Trace javax.servlet.ServletException javax.faces.webapp.FacesServlet.service(FacesServlet.java:667) io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86) io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) filters.LoginFilter.doFilter(LoginFilter.java:44)
Here the Xhtml code:
<p:column style="text-align: center" headerText="Télécharger">
<p:commandButton value="Download" ajax="false"
onclick="PrimeFaces.monitorDownload(start, stop);"
icon="ui-icon-arrowthick-1-s">
<p:fileDownload value="#{fileDownloadView.file}" />
<f:setPropertyActionListener value="#{a}"
target="#{demandeBean.demandeSelectionnee}" />
</p:commandButton>
</p:column>
Here the java Bean code :
public class FileDownloadView {
private StreamedContent file;
public FileDownloadView() {
InputStream stream = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(
"http://localhost:18080/openCars/images/hichem.jpg");
file = new DefaultStreamedContent(stream, "image/jpg", "downloaded_optimus.jpg");
}
public StreamedContent getFile() {
return file;
}
}