Passing Variable to Java Through JSP?
Question: I'm wondering if it is possible to pass form data from index.jsp file to a
java class and then back to the response.jsp. I'm trying to compute something
with the data they have entered into index.jsp but it can't be done in
Javascript. Is there a way that I can retrieve the data?

The other thing is using http servelts and writing the entire html in Java,
but that seems overly complex and not worth the effort if there are simpler
ways of doing this.

Thanks in advance for the help!

This is one of the scripts (in javascript) that I written to try and solve
this problem, but my class, RunPython.java, always comes an error?

    
    
    <script type="text/javascript">
    
    function onSubmit(){
       var Bugfile = document.forms[0]["BugFile"].value;
       var GD = document.forms[0]["GD"].value;
    
    <%
    String s = request.getParameter("Bugfile"); 
    String d = request.getParameter("GD");
    RunPython re = new RunPython(s,d);
    %>
    
    }
    

**Error:**  
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP

PWC6197: An error occurred at line: 61 in the jsp file: /index.jsp PWC6199:
Generated servlet error: string:///index_jsp.java:106: cannot find symbol
symbol : class RunPython location: class org.apache.jsp.index_jsp

PWC6197: An error occurred at line: 61 in the jsp file: /index.jsp PWC6199:
Generated servlet error: string:///index_jsp.java:106: cannot find symbol
symbol : class RunPython location: class org.apache.jsp.index_jsp


Answer: > Generated servlet error: string:///index_jsp.java:106: cannot find symbol  
>  symbol : class RunPython  
>  location: class org.apache.jsp.index_jsp

The compiler is just trying to tell you that it cannot resolve the mentioned
class in any of the imports. You need to import the mentioned class in JSP.

    
    
    <%@ page import="com.example.RunPython" %>
    

This has **nothing** to do with passing variables around, although your
attempt seems to be pretty clumsy, but this is subject to a new question.

* * *

**Unrelated** to the concrete problem, you seem to misunderstand the purpose
and capabilities of servlets. They are not meant to write the HTML entirely in
it. Just only Java code. Start at [our servlets wiki
page](http://stackoverflow.com/tags/servlets/info) to learn about them.

