Capture Java JavaScript variables

1

I would like to capture JavaScript variables in a Java class.

For example, I am working with digital signatures on the client side and I need to verify the server side signature. So, I need the signature that I generated from the browser, which is in a variable.

How could I do this?

    
asked by user76173 20.02.2018 в 20:54
source

1 answer

0

Please note that the server code (Java) is executed before the client code (Javascript). One recommendation is to send the value from Javascript to the server. It will depend on the framework that you use the way. In jquery it would be:

Send data to a remote page:

$.ajax({
  url: "ruta/al/controlador",       //La dirección de tu controlador
  method: 'POST',                   //El método, get o POST
  data: {'firma': '11989798798'}    //Los datos que enviarás al servidor
}).done(function() {
    //Lo que harás luego que la función en el servidor se ejecute
  alert( "firma verificada" );
});

It would only be necessary to capture the data on the server and that's it.

EDITED Reference: In English . The last code block of the question has the server part, you have to include the necessary library but it can help you more to build your solution.

    
answered by 20.02.2018 в 21:14