I got something like this:
package beans;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("cc")
@Stateless
public class CardBean implements ICardRemote {
@Produces(MediaType.APPLICATION_JSON)
@Path("validate/{creditCard}")
@GET
@Override
public boolean Validate(@PathParam("creditCard")String creditCard){                 
    int sum = 0;                    
     boolean alternate = false;                 
     for (int i = creditCard.length() - 1; i >= 0; i--)                 
     {                         
        int n = Integer.parseInt(creditCard.substring(i, i + 1));                          
        if (alternate)                        
        {                                
             n *= 2;                                 
             if (n > 9)                              
            {                                
                n = (n % 10) + 1;                               
            }                         
         }                         
         sum += n;                        
        alternate = !alternate;                 
    }           
    return (sum % 10 == 0); //or true or false
}
}
There I got the function Validate
Now I got a HTML page, that looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="code.jquery.com/jquery-3.1.1.min.js"; integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous">      </script>
</head>
<body>
<a
    href="http://localhost:8080/CreditCardWEB/rest/cc/validate/4111111111111111">Validan</a>
<br>
<a
    href="http://localhost:8080/CreditCardWEB/rest/cc/validate/4111111111111112">Nevalidan</a>
<br>
<br>
<input type="text" name="txtCC" value="4111111111111111" id="txtCC1">
<button name="btn" onclick="myFunction()">Click me!</button>
<br>
<br>
<p id="res">Result: </p>
<script>
function myFunction() {
    //    document.getElementById("res").innerHTML = "Result:" + txtCC1.value;
        var str = txtCC1.value;
         $.ajax({
            type: 'GET',
            url: './validate/'+str,                 
            success: function(data) {                               
                     document.getElementById("res").innerHTML = "Result:" + data;          
            },
            error: function(jqXHR, textStatus, errorThrown) {
                        //Do something on ERROR here                            
            }
        });                 
}
</script>
<br>
</body>
</html>
So in the end, I have a text field, with a hardcoded number in it.
On button click I need to take that number and send it into my validation function.
And once the function is done, I need the result to be written below the button.....here...
<p id="res">Result: </p>
So it has to be like Result:true, or Result:false