• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing (session) attributes from JavaScript code

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is their any way to access/modify session attributes by JavaScript.



I can't do it as above, because the id is subjected to be changed after the page load. So, can you please tell me how to access the current value of a session attribute?
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you know, javascript runs entirely on the client and the session object access that you posted runs on the server.

Since the session object is dedicated to the current user, why would the 'id' change without the page knowing it?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see this this article to understand how JSPs work.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to contact the server after page load, but without submitting the page, then Ajax is your best bet.
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
If you need to contact the server after page load, but without submitting the page, then Ajax is your best bet.


Hi Bear,

I already used Ajax for this implementation. After that I've posted this topic to see is their any optional way available for this.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Optional? What do you mean by that?

To access the server, you submit the page or use Ajax.
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Optional? What do you mean by that?


I mean something which can be used instead of Ajax. Is it a wrong word in English?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to post a form back, make an Ajax call, open up a new window, open up an iframe, set an image source to a file on the server, or any other means that you can make an http request to the server.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic