Java-applet java.Sicherheit.AccessControlException

Arbeite ich an einer Java-applet, das druckt eine Datei.
Das applet ist "self-signed".

Die print-Funktion:

//argFilePath : path to file (http://localhost/Teste/pdf1.pdf)
//argPrintService : something like PrintServiceLookup.lookupDefaultPrintService()
private int print(String argFilePath, PrintService argPrintService){
    try 
    {   

        DocPrintJob printJob = argPrintService.createPrintJob();
        Doc doc;
        DocAttributeSet docAttrSet = new HashDocAttributeSet();
        PrintRequestAttributeSet printReqAttr = new HashPrintRequestAttributeSet();


            URL url = new URL(argFilePath);
            doc = new SimpleDoc(url.openStream(), DocFlavor.INPUT_STREAM.AUTOSENSE, docAttrSet);


            printJob.print(doc, printReqAttr);



    } catch (Exception e) {
        System.out.println(e);
        return 1;
    }

    return 0;
}

Bekomme ich diese exception beim Versuch, die Datei zu öffnen:

java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:80 connect,resolve)

HTML/JavaScrip

<input onclick="alert(document.getElementById('xpto').print('http://localhost/Teste/pdf1.pdf'));" type="button"/>

 <applet width="180" height="120" code="printers.class" id="xpto" archive="printerAPI.jar"></applet>

korrekt zu verwenden:

DocFlavor.INPUT_STREAM.AUTOSENSE

Die Idee zu sein scheint, drucken Sie so viele Dateitypen wie möglich - pdf, docx, jpg, etc.

Wie kann man das lösen Ausnahme?

InformationsquelleAutor V1tOr | 2011-03-26

Schreibe einen Kommentar