# How does one deal with JWT Token Validation from a Javascript client in a Servlet Filter w/o Spring?

**URL:** <https://community.auth0.com/t/how-does-one-deal-with-jwt-token-validation-from-a-javascript-client-in-a-servlet-filter-w-o-spring/8240>\
**Category:** Get Help\
**Tags:** java-ee, servlet, javascript\
**Created:** [September 19, 2017, 9:58am UTC](https://community.auth0.com/t/how-does-one-deal-with-jwt-token-validation-from-a-javascript-client-in-a-servlet-filter-w-o-spring/8240 "2017-09-19T09:58:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![horsephotostechnolog](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@horsephotostechnolog](https://community.auth0.com/u/horsephotostechnolog)\
**Post date:** [September 19, 2017, 9:58am UTC](https://community.auth0.com/t/how-does-one-deal-with-jwt-token-validation-from-a-javascript-client-in-a-servlet-filter-w-o-spring/8240/1 "2017-09-19T09:58:50Z")

</div>

This example is woefully under documented

From this page:

> **[GitHub - auth0/java-jwt: Java implementation of JSON Web Token (JWT)](https://github.com/auth0/java-jwt)**
>
> Java implementation of JSON Web Token (JWT)

Where and how do I get/set the public/private key? When a accessToken is generated in my Javascript client and passed to me?  
How do I secure a restful endpoint, and why doesn’t the generated war file just deal with this case automatically? i.e. passing around accessTokens, idTokens and all the other values that my javascript client generated.

```
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9.AbIJTDMFc7yUa5MhvcP03nJPyCPzZtQcGEp-zWfOkEE";
RSAPublicKey publicKey = //Get the key instance
RSAPrivateKey privateKey = //Get the key instance.
try {
    Algorithm algorithm = Algorithm.RSA256(publicKey, privateKey);
    JWTVerifier verifier = JWT.require(algorithm)
        .withIssuer("auth0")
        .build(); //Reusable verifier instance
    DecodedJWT jwt = verifier.verify(token);
} catch (JWTVerificationException exception){
    //Invalid signature/claims
}

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/how-does-one-deal-with-jwt-token-validation-from-a-javascript-client-in-a-servlet-filter-w-o-spring/8240/2 "2018-03-02T05:56:35Z")

</div>


