but how to transfer the information from the fields to java on the server program
How it is done everywhere: via GET or POST-parameters.
Fields on the page are usually attached to the form. The form has a method attribute that indicates which HTTP method to use to send data. Suppose the form fields are named param1 and param2 :
- if the
GET method is specified, the field values will be in the form of address parameters: http://.......?param1=...¶m2=... In this case, on the server side, you will need to access the parameter like this (depending on the selected server): httpRequest.getParameter("param1") ; - if the
POST method is specified, the field values will be sent in the body of the POST request, packed in the application/x-www-form-urlencoded or multipart/form-data . For example, param1=Some+Value¶m2=%40 . You can get the values by retrieving the request body and decrypting it. Something like URLDecoder.decode(httpRequest.getRequestBody()) .
In general, I recommend to start with the HTTP protocol and its methods. When it comes to the realization that working with the protocol does not depend on the language and in fact you are accessing the same primitives, it will be easier to search for information.
Shl. In order not to engage in cycling on primitive tasks, you can try to use the web server built into the JVM (this is not for serious production, of course):
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); server.createContext("/", new HttpHandler() { @Override public void handle(HttpExchange httpExchange) throws IOException { // тут ваш обработчик запросов httpExchange.sendResponseHeaders(200, 0); httpExchange.close(); } }); server.start();
For something serious, you can take, for example, Jetty - it can be easily embedded in any application.