• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Send and receive a token on each request

 
Ranch Hand
Posts: 128
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can somebody help me to understand, how to receive a token from header in Javascript ?
I am almost done withe token creation activity, sending it on header, just want to understand how can I recieve a token on UI side in Javascript?

Thanks,
Atul
 
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A token for what?
 
Atul More
Ranch Hand
Posts: 128
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A token for validating each request.
Whenever any request comes to backend, it create a token send it back to UI and for next request the last genereated token send it back to backend. So in response, it send it back new token.
UI is in Javascript and backend in Java, Spring
 
Saloon Keeper
Posts: 5581
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How it it sent back, exactly? Is it part of the HTML body?
 
Atul More
Ranch Hand
Posts: 128
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

Not with body, by using header
 
Tim Moores
Saloon Keeper
Posts: 5581
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's using XMLHttpRequest (or a library that make use of it), then that has methods to get the headers. Otherwise, it's not possible.
 
Stephan van Hulst
Saloon Keeper
Posts: 10308
217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are the tokens sent in a header? What frameworks are you using in the front- and backend? In response to what are you sending AJAX requests?
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are plenty of tokens already sent in headers. Many of them are sent automatically. That's what cookies are.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!