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

h1400046a at 2007-7-8 22:01:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
please help?
h1400046a at 2007-7-8 22:01:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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?)

evnafetsa at 2007-7-8 22:01:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
so if i create a additional jsp that handles the save called save.jsp and then read in the values and save them from there and then re-direct the user to the next page after (save.jsp isnt a page) then itll workthanks
h1400046a at 2007-7-8 22:01:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
To call java from javascript you can use the Ajax library DWR from http://getahead.ltd.uk/dwr/examples/text
Niklasa at 2007-7-8 22:01:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...