how to call java classes from javascript?
i have a button which calls javascript i need to access a class to update the values in the database.. how do you call the java code from within the javascript?
the class is stored under tomcats classes directory and is accessed:
com.Database.Employee
the method is called : UpdateEmployeeDetails
the button
<input type="button" value="Save" onclick="submitForm('save')" />
the javascript
<script language="javascript">
function submitForm(process){
document.myForm.action="update.jsp";
document.myForm.submit();
}
</script>
[800 byte] By [
h1400046a] at [2007-11-26 15:42:47]

# 1
is it not possible?
do i have to refresh the page and read in the values like...
<%
String ename = request.getParameter( "EmployeeName");
session.setAttribute( "ename", ename);
%>
and then call the class from here?
............................
looking around ive come across ajax but i dont know how to use it and what you need to install and if its compatable with tomcat and jsp?
is ajax better or not really worth it?
i have anything up to 100 fields that need saving at one save click
# 3
To answer your question, javascript can not call java code.
Java/JSP runs on the server.
Javascript runs on the client in the browser.
At the point you submit your form, it makes a request to a JSP/Servlet.
In that JSP/Servlet is where you need to put the code to retrieve the submitted parameters from the page (request.getParameter), and then "save" them (presumably some sort of database code?)