I am letting the user upload a file and am storing it as so
List<Meetingsattachment> mal= new ArrayList<Meetingsattachment>();
    meeting.setMeetingsattachments(mal);
    Random rand=new Random();
    int num=Math.abs(rand.nextInt());
    String dirname="/path/to/files/"+meeting.getDescription()+"-"+num;
    File dir= new File(dirname);
    System.out.println(dir.getAbsolutePath());
     if(! dir.exists()) 
          dir.mkdir();
     for(UploadedFile uf:ufl){
         Meetingsattachment ma=new Meetingsattachment();
         ma.setAttachment(dirname+"/"+uf.getFileName());
         File file = new File(dirname+"/"+uf.getFileName());
            try (FileOutputStream fop = new FileOutputStream(file)) {
                // if file doesn't exists, then create it
                if (!file.exists()) {
                    file.createNewFile();
                }
                // get the content in bytes
                fop.write(IOUtils.toByteArray(uf.getInputstream()));
                fop.flush();
                fop.close();
                meeting.addMeetingsattachment(ma);
                System.out.println("Done");
            } catch (IOException e) {
                e.printStackTrace();
            }
     }
    int meetingid=mrm.addMeeting(meeting);
    return "meetings?faces-redirect=true";
What I am basically doing is taking the file storing it at /path/to/files/ and then storing the location in my database, so value in db is as so
/path/to/files/t2-672409104/1.pdf
I am able to download the file as so
Meetingsattachment ma=(Meetingsattachment) actionEvent.getComponent().getAttributes().get("attachment");
        //System.out.println("here  "+form.getRqid());
        try{
        InputStream stream = new FileInputStream(new File(ma.getAttachment()));
        String fl=ma.getAttachment(); 
        System.out.println(fl);
        String filename=fl.split("/")[5];
        //System.out.println(ra.getRaid());
        setFile(new DefaultStreamedContent(stream,"application/pdf",filename));
in the jsf
<ui:repeat var="meetattachment" value="#{meet.meetingsattachments}">
                <h:outputText value="#{meetattachment.attachment}" />
                <p:commandButton icon="ui-icon-arrowthickstop-1-s"
                        onclick="PrimeFaces.monitorDownload(showStatus, hideStatus)"
                        actionListener="#{meetBean.buttonAction}">
                        <f:attribute name="attachment" value="#{meetattachment}"></f:attribute>
                        <p:fileDownload value="#{meetBean.file}" />
                    </p:commandButton>
But when I try to display the file in an iframe I just get an iframe showing resource not found
<ui:repeat var="meetattachment" value="#{meet.meetingsattachments}">
                <h:outputText value="#{meetattachment.attachment}" />                   
                    <p:lightBox iframe="true">
                    <h:outputLink value="#{meetattachment.getAttachment()}">
                    preview2
                    </h:outputLink>
                    </p:lightBox>
                    <br />
            </ui:repeat>
The value that the h:outputlink is getting is /path/to/files/t2-672409104/1.pdf
In the developer webconsole I can see the following error
GET 
http://localhost:8080/path/to/files/t2-672409104/1.pdf not found
so I think the problem is the path it is trying to use to find the file, from my understanding if I store the file using the relative path /path/to/files the actual path for the file is C:\path\to\files
I tried hardcoding the value as such just to test
<h:outputLink value="C:\path\to\files\t2-672409104\1.pdf">
I get a message saying it cannot understand the protocol C
So my question basically is how do I provide the path to these files to open them in a frame
 
     
    