0

我正在运行一个小程序,它将在客户端机器中复制 jar 文件。我可以使用小程序复制 jar 文件,但是当我使用 jsp Appet 调用同一个小程序时不起作用。知道如何执行该操作。我已经烧掉了我的小程序,也没有任何异常。

package APPLET;

import java.applet.Applet;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class SET_UPFILE extends Applet {


    public void init() {
        File sourceFile = new File("G:\\KERALA\\ojdbc14.jar");
        File destinationFile = new File("G:\\backup\\" + sourceFile.getName());
        SET_UPFILE copyFileExample1 = new SET_UPFILE();
        copyFileExample1.copyFile(sourceFile, destinationFile);
    }

    public void copyFile(File sourceFile, File destinationFile) {
        //   System.setSecurityManager(null);
        try {
            FileInputStream fileInputStream = new FileInputStream(sourceFile);
            FileOutputStream fileOutputStream = new FileOutputStream(destinationFile);

            int bufferSize;
            byte[] bufffer = new byte[512];
            while ((bufferSize = fileInputStream.read(bufffer)) > 0) {
                fileOutputStream.write(bufffer, 0, bufferSize);
            }
            fileInputStream.close();
            fileOutputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

这是我调用那个小程序的jsp页面

<%@page import="java.io.File"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//HI"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title>applet</title>
        <script type="text/javascript">
            function startApplet(id) {
                var Projectpath="";
                var ProjectPath = document.getElementById('Projectpath').value;
                alert(ProjectPath);
                id = ProjectPath+"//"+ProjectPath;
                appletsource="<applet code='APPLET.SET_UPFILE.class' \n\
                               name='QuantumAeonGENIE1' \n\
                               id = 'QuantumAeonGENIE1'     \n\
                               codebase='./'   \n\
                               archive='MYAPPLET.jar' \n\
                               width='500' height='500' >\n";
                appletsource+="<PARAM name='message' value='"+id+"'>\n";
                appletsource+="</applet>\n";
                document.getElementById("appletdiv").innerHTML=appletsource;
            }
        </script>
    </head>
    <body leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px" SCROLL=NO>
        <form name="frmEntry" id="frmEntry" onsubmit="frmSave" method="post">
            <div id="MainDIvReport" align="center">
                <div id="FieldDiv">
                    <div id="toPrint1"
                         <center>
                            <div id="TitleDivReport" align="center">
                                <b>ETM ISSUES AND AUDIT -> TICKET DOWNLOAD</b>
                            </div>
                        </center>
                    </div>
                    <div id="appletdiv" style="text-align: center;">

                    </div>
                    <%
                        File sourceFile = new File("");
                        String StrPath = sourceFile.getAbsolutePath();
                       // System.out.println(StrPath);
                    %>
                    <input type="hidden" id="Projectpath" name="Projectpath" value="<%=StrPath%>" ></input>
                    <table border="1" id="CntrlTABREPORT">
                        <tr>
                            <td align="left" style="width: 85%;">
                            </td>
                            <td align="right" style="width: 15%;">
                                <div  align="center" id="CntrlDivReport">
                                    <table id="tab-button">

                                        <tr>
                                            <td>
                                                <input type="button" id="QAGenieCheckstatus" name="QAGenieCheckstatus" value="STATUS"  onclick="startApplet(id)" />
                                            </td>
                                        </tr>

                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                    </br>
                    </br>
                    <center><h1></h1></center>
                </div>
                <div id="toPrint">
                    <div style="display: none;">
                        <jsp:include flush="true" page="/DROPDOWN_1.jsp"></jsp:include>
                    </div>
                    <div id="div-display-outer">
                        <div id="div-display">

                        </div>
                    </div>
                </div>
            </div>                  
        </form>

        <table border="0" width="100%" bgcolor="#085DAD" id="div-footer">
            <tr>
                <td valign="bottom" align="center">

                </td>
            </tr>
        </table>
    </body>
</html>
4

1 回答 1

0

我找到了解决方案..我不确定,但是当我从控制面板启用 java 控制台输出然后运行相同的代码时,它就可以工作了。

于 2013-09-19T10:03:01.560 回答