JSP call javascript function through href
<p>The following code in JSP: </p>

<pre><code>while(rs2.next()) 
    { 
        out.println(rs2.getString(1));
        %&gt;
            &lt;a href="javascript:displayData(&lt;%=rs2.getString(1)%&gt;)"&gt;Run The App&lt;/a&gt;
        &lt;%
        out.println("&lt;br&gt;");
    }
</code></pre>

<p>I want for each element to print its name and a link to JavaScript function that takes the name as a parameter.</p>

<p>The JavaScript that I have is:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function displayData(ctr) {
        alert(ctr);
        &lt;%
            Process p = null;
            Runtime r = Runtime.getRuntime(); 
            String command; 
            File dir = new File("C:/app/webapps/data"); 
            command="javaw -jar "+ctr;
            try 
            { 
                p = r.exec(command,null,dir);
            }
            catch(Exception e) 
            { } 
        %&gt;
    }
&lt;/script&gt;
</code></pre>

<p>What the function does is to execute a jar file (the jar file is executed by calling its name which in this case the parameter that I pass <code>ctr</code>). The error that I got is:</p>

<pre><code>ctr cannot be resolved to a varialbe
</code></pre>

<p>Can someone help me in this problem?</p>