I've wrote a bean that takes photos from a webcam. I'd like to display these image in a JSF 2.0 page and update them every n second.
If I give the path name the file in eclipse like this it work:
public String getNewPhoto() {
try {
File dir = new File("C:/Users/User/MyApp/images/");
FileUtils.cleanDirectory(dir);
}catch(Exception ex) {
ex.printStackTrace();
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
try {
webcam = Webcam.getDefault();
webcam.open();
ImageIO.write(webcam.getImage(), "PNG", new File("C:/Users/User/MyApp/images/"+ timeStamp + ".png"));
webcam.close();
}catch(Exception ex) {
ex.printStackTrace();
}
return "C:/Users/User/MyApp/images/" + timeStamp + ".png";
}
With the following XHTML:
<p:graphicImage value="#{myBean.newPhoto}" id="photo" cache="false" />
<p:poll interval="1" listener="#{myBean.increment}" update="photo" />
As expect all of the above works fine from my dev environment on eclipse. I'd like to deploy this to my server (Linux). When I change the paths from what you see above to
/var/lib/tomcat7/webapps/MyApp/images
Then the images get saved, but I can't display them in h:graphicImage. I also tried passing:
http://hostname:8080/MyApp/images/....
to h:graphicImage and still no dice, I'm sure I'm missing something real simple. Any help is appreciated!