title: Involk javascript function in Java
body: <p>I am trying to call a simple javascript method in my Java code.  Basically I want to show a textbox on my jsp page that is displayed when you click on a button.  After I hit submit the textbox is gone, I want to keep the textbox on display.</p>
  
  <p>Here is my front end code:</p>
  
  <pre><code>&lt;input name="mytext" type="text" id="text" style="display:none;"/&gt;
  </code></pre>
  
  <p>Here is my Java code where I am trying to force the textbox to stay displayed after submit:</p>
  
  <pre><code>if(isClean==true &amp;&amp; hasError==false)
  {
  ScriptEngineManager manager = new ScriptEngineManager();  
                      ScriptEngine engine = manager.getEngineByName("JavaScript");  
                                             //using the text id in my jsp page
  String myscript = "function Show() {document.getElementById('text').style.display = 'block'; }";  
   // evaluate script  
  engine.eval(script);  
  
  
   Invocable inv = (Invocable) engine;  
  
  inv.invokeFunction("Show" ); 
              }
          }
  </code></pre>
  
  <p>I have a function in my Javascript that functions very well off the same function, however, when I call it from Java, it just does not seem to want to work.</p>
  
  <p>Any suggestions would be great and thanks for your help.</p>