Fubundzer Fubundzer - 1 year ago 96
reST (reStructuredText) Question

Can I access HTTP header this way?

So I've been trying to create token based authentication in

Java EE
lately and I tried to sent token via HTTP Header, but failed so many times.

My question : If I have for example
response method and I set header via return response statement

return Response.ok(entity).header(HttpHeader.AUTHORIZATION, authToken).build()

Then I invoke other method that was binded to
and in this filter I try to access header via

then should it work?

Will I get the value from that header that was set in response method? If not then what should I do to get value of this header in filter method?

Answer Source

The Authorization header(or any other header) must be included by the client in each request

Your client should get the token from the server response, keep it in a secure storage and set the Authorization header when performs a request. Then, with RequestContextFilter your server will be able to recover it

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download