title: Run a python script on a button click in jsp
body: <p>I have a requirement where I need to run a python script on a button click and pass the input parameters (depending what option the user selected from the drop-down in the front end) to the python script which will run in a server and return the result if the script ran successfully or not to the webpage.</p>
  
  <p>Achieving to run a script on a button click-should i do it with jsp or java end.
         I tried in java the following code.     </p>
  
  <pre><code>Process p;
  p=Runtime.getRuntime().exec("python set path=%path%;C://Python27  WEB-INF/hello.py");
  </code></pre>
  
  <p>I get this error.</p>
  
  <blockquote>
    <p>java.io.IOException: Cannot run program "python": CreateProcess error=2, The system cannot find the file specified</p>
  </blockquote>
  
  <p>Where should I place my python script inside the web project?
  (or)
  Should I use javascript to run the script.</p>
  
  <pre><code>&lt;script type=text/javascript&gt;
       $(document).ready(function () { // Make sure the elements are loaded on           the page
          // Listen for a click event on the button
        $('#Submit').click(favfunct);
       });
  
       function favfunct(e) {
        $.ajax("WEB-INF/hello.py", {
          cache:false,
     dataType: "script",
     method:"POST",
     async:asynchronous,
      success: function (response) {
  
           alert ("successfully loaded")
      }
   });
  }   
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Nothing happens when I submit.
  Also could you please give me some pointers in achieving this requirement?</p>
  
  <p>Thanks a ton!!</p>