0

I am encountering the following exception: javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "document" is not defined. (#21) in at line number 21

After I call the enable download button it calls a javascript function which isnt able to identify the "document"

User.jsp

<form class="form-horizontal" action="Download.jsp" method="POST" id="myForm" onsubmit="beforeSubmit();" onreset="enableDownloadButton();">
                <div class="row">
                    <div class="col-sm-6 widget-container-span ui-sortable">
                        <div class="widget-box transparent">
                            <div class="widget-body"><div class="col-sm-12">
<button class="pull-right btn btn-primary btn-sm" type="submit" id="saveId" onclick="flag=1;"> 
                                                        <i class="icon-search bigger-110"></i> Download Report</button>

Download.jsp:

 try {
            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine javascriptEngine = manager.getEngineByExtension("js");

            // Get script from JS File
            FileInputStream fileInputStream = new FileInputStream("C:/Users/ox3404/Desktop/Dashboard/WebContent/js/UserReport.js");
            System.out.println("before if fileinput");
            if (fileInputStream != null) {
                BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));

                javascriptEngine.eval(reader);
                invocableEngine = (Invocable)javascriptEngine;

                invocableEngine.invokeFunction("enableDownloadButton");

                //System.out.println("Result: " + object);
            }
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }

Javascript File:

function enableDownloadButton()
{
    document.getElementById("saveId").disabled=false;

}

0 Answers0