简体   繁体   English

在Web浏览器上使用Java Applet的权限

[英]Permission for java applet to be used on web browser

I have created an applet that I would like to run on web browser. 我创建了一个要在Web浏览器上运行的小程序。 The applet contains features such as sending an email and opening another applet using URI. 该小程序包含诸如发送电子邮件和使用URI打开另一个小程序之类的功能。

The interface works fine. 界面工作正常。 However, 然而,

these parts seem to need a permission. 这些部分似乎需要许可。

...........................................................
    //creating session
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));

    // to add recipients 
    InternetAddress[] toAddress = new InternetAddress[to.size()];

    // To get the array of recipients addresses
    for( int i=0; i < to.size(); i++ ) { 
        toAddress[i] = new InternetAddress(to.get(i));
    }
    System.out.println(Message.RecipientType.TO);

    //adding recipients
    for( int i=0; i < toAddress.length; i++) { 
        message.addRecipient(Message.RecipientType.TO, toAddress[i]);
    }
    message.setSubject(subject);
    message.setText("This is Zaid's app");


   // check if animation was selected
    if(animation)
     fileName= attachment +".gif";
    else
     fileName = attachment +".JPEG";

    //add the attachment
    MimeBodyPart attachMent = new MimeBodyPart();
    FileDataSource dataSource= new FileDataSource(new File("ScaryImages//"+ fileName));
    attachMent.setDataHandler(new DataHandler(dataSource));
    attachMent.setFileName(fileName);
    attachMent.setDisposition(MimeBodyPart.ATTACHMENT);
    Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(attachMent);
    message.setContent(multipart);


    //this is the sender variable
    Transport transport = session.getTransport("smtp");

    //trying to send...
    try{
    System.out.println("connecting...");
    transport.connect(host, from, pass);

    System.out.println("sending...Please wait...");
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
    System.out.println("sent");

    JOptionPane.showMessageDialog(null,"Your Email has been sent successfully!");
    }

    catch(Exception e)
    {
        //exception handling, the problem is mainly the connection
        JOptionPane.showMessageDialog(null,"Connection Problem has been detected! Please Try again.");
        e.printStackTrace(System.out);

    }

    //remove loading label anyway
    finally{

        EmailApplet.removeLoadingLabel();
    }
   .......................

also this, 还有这个

try { 尝试{

        java.net.URI uri = new java.net.URI( arg );
        desktop.browse( uri );
    }

Can you please tell me what permission and where should I provide? 您能告诉我什么许可,我应该在哪里提供? Thank you 谢谢

If you want to open a new page, in another tab or window, try this: 如果要打开新页面,请在另一个选项卡或窗口中尝试以下操作:

getAppletContext().showDocument(url.toURI(), "_blank");

"_self" Show in the window and frame that contain the applet. “ _self”在包含小程序的窗口和框架中显示。
"_parent" Show in the applet's parent frame. “ _parent”在小程序的父框架中显示。 If has no parent frame, acts the same as "_self". 如果没有父框架,则与“ _self”相同。
"_top" Show in the top-level frame of the applet's window. “ _top”显示在小程序窗口的顶级框架中。 If the applet's frame is the top-level frame, acts the same as "_self". 如果小程序的框架是顶级框架,则其作用与“ _self”相同。
"_blank" Show in a new, unnamed top-level window. “ _blank”在一个未命名的新顶级窗口中显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM