I am new to web development, and I am writing a little test site to learn some stuff. But I'm not sure how to send data to the server that is not in a form. I have two specific questions at the end of this post, but I'll try to give the relevant details first:

I enter a url in my browser that maps to a JSP on the server (JBoss/Tomcat on the server side). That JSP reads products from a database and presents a little 'shop' on the browser.

When the user adds an item to their cart, I make an Ajax call to the server, which adds to the cart and returns xml representing the cart contents.

There is an image on the web page that takes the user to the shopping cart page where they can submit an order. When they click the "checkout" image, the follow Javascript is called:

var req = new XMLHttpRequest();
req.open("GET", "checkout", false);

if (req.status == 200)
var doc = req.responseText;

The checkout servlet writes html which contains a form for the user to enter their delivery details. As you will see, I wait for the servlet to send its response and then I overwrite the current document with it.

Question1 - What I'm doing seems wrong to me. I'm sure I should just be going to another page, a "checkout" page, rather than overwriting the current document. But as my checkout button is not in a form I don't know how to do that.

Question2 - my second question is that when I submit the form with the delivery details on it, I do not have the parameters I expect when the request hits my servlet. Instead of "CustomerName", "AddressLine1" etc, the only parameters I have are "x" and "y", both of which contain a number (a different number each time).

Many Thanks,