Search code examples
javazk

retrieve a picture stored in a folder Zk Tomcat


I'm new in zk programming, I had stored pictures from my app to a folder out the server(tomcat) and I want to retrieve it , the folder is c:\temps and supposing the picture names is myPic.jpg when I write pics.setSrc("c:\temps\myPic.jpg"); it doesn't work for me what could I do to fix it the storage is very well but retrieving the picture is working only on the Eclipse IDE but in other browsers it's not working

@Wire
private org.zkoss.zul.Image pics; 
private static final String SAVE_PATH = "C:\temps\";
private ProfileDao pd = new JpaProfileDao();
private ListModel<profile> profileModel;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
profileModel = new ListModelList<Profile>(pd.findAll());
prfileSelect.setModel(profileModel);
String src="C://tmp//testimg.jpg";
pics.setSrc(src);
Clients.showNotification(pics.getSrc());
}

in the browser I have these problem

Not allowed to load local resource:file:///C://temps//testimg.jpg

Solution

  • you're trying to access to a file in the server side ,the server doesn't know about your disc so use the aliases for tomcat

           <Context crossContext="true" docBase="here_the_path_in_disc" path="project_name/resource_name" reloadable="true"/>