How does a form's data capture work?

9

I have this code to get data from a form:

@WebServlet(name = "computador", urlPatterns = {"/computador"})
public class computador extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        float total = Float.parseFloat(request.getParameter("total"));
        float preco = Float.parseFloat(request.getParameter("preco"));
        float consumo = Float.parseFloat(request.getParameter("consumo"));
    }

}

But I do not know why it uses request to get the data, instead of response . And what is response ?

    
asked by anonymous 08.02.2016 / 17:45

1 answer

8
  

Request is to send requests to the server.

     

Response is the response from the server to the client.

An application or web system works totally differently from a desktop or console where all processing takes place on the local machine.

A web application must obey the http protocol cycle, which works in two times: request and response.

The term request means that the client (a browser for example) is making a request to the server for some feature, be it an html page, image, download etc. the server receives and processes the request and returns something can be html, json etc that return is given the name of response .

    
08.02.2016 / 18:11