How to get data from javaScript in a servlet?

  • 0
    Hello. Please help me solve the problem. Given a page jsfiddle.net/parkito/7eozjym1/1

    After entering data into the fields and clicking on the sent button, I need the contents of the fields to go to the servlet array. I don't quite understand how to extract data from this javaScript and send it to java.
    Java Anonymous, Apr 28, 2020

  • 1 Answers
  • 0
    In general, to send a form, it is enough to specify method (post / get) and action - the actual link to the servlet.

    And all inputs from of this form will be sent to the specified servlet.


    If you need it in js, then by pressing call the function in which to send an ajax request to the servlet.

    $.ajax({
    method: "POST",
    url: "/servlet",
    data: {
    parav1: value1,
    param2: value2
    }
    })
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!