• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

JavaScript and Ajax

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do i get request.getSession.getAttribute("xyz") in javascript ? How to assign this to header in ajax call?
 
Saloon Keeper
Posts: 6515
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sessions are a server-side concept - the client side has no access to them. And since any server-side code already has access to them, there's no need to send them in the first place.
 
mahitha rao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:Sessions are a server-side concept - the client side has no access to them. And since any server-side code already has access to them, there's no need to send them in the first place.




yeah but how can i set that value to a header in ajax call?
 
Tim Moores
Saloon Keeper
Posts: 6515
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain why you want to do that. As I said, there is no point in doing so because the server already has everything available that is in the session.
 
mahitha rao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we have rest API calls from javascript. depending on that request.getSession().getAttribute("xyz") value we need to set the header in the rest API call.
 
Tim Moores
Saloon Keeper
Posts: 6515
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could embed the value as a JavaScript variable when you generate the page - since intend to use it within JavaScript anyway.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic