R
R
Ruslan2019-04-19 19:53:27
RESTful API
Ruslan, 2019-04-19 19:53:27

Client not getting response from server REST, JAVA?

There is this form:

<form name="user" action="POST">
           Email: <input name="email" required type="email" />
           Password: <input name="password" required type="password" />
           Login:<input name="login" required type="text">
            <input type="submit" value="Submit" onclick="registration()" />
           </form>

The registration method that is called on click
var xhr = new XMLHttpRequest();
function registration()
{
 xhr.open("GET", "http://localhost:8080/user/login", true);
 xhr.send();
 success:  alert('Succes');
}

And here is the class itself, the method that handles the given HTTP "GET" request
@GET
    @Path("/register")
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces({MediaType.APPLICATION_JSON})
    String user_info(@PathParam("email") String email, @PathParam ("password") String password ) throws FileNotFoundException{
        return "succes";   
    }

For several days I have been trying to understand what is wrong, the error is 100% stupid and is associated with an incomplete understanding of the topic, so I will be glad for your help.
The essence of the problem is that when the button is clicked, the registration () method is called, but js does not find the method processing it on the server at the specified path and issues 404 not found.
glassfish 5 server, Maven builder

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question