Aleksandra Anakijeva wrote: this is my script
out.println("<script language='javaScript'>");
out.println("function Add(int a) { return ++a;}");
out.println("</script>");
...........
this is is the code of final servlet.

Write a plain HTML page for displaying the buttons and add Javascript to it. Let the page submit to the servlet.
DO NOT write Javascript in servlet, never.

Hi,
This can be done in many ways.
My suggestion is use jquery button click events for both buttons.
Have two global variables corresponding to click counts of the two buttons.
When you click on final submit button then submit the variables using ajax request to servlet.
At servlet try to get the params and process them