This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Accessing (session) attributes from JavaScript code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Accessing (session) attributes from JavaScript code" Watch "Accessing (session) attributes from JavaScript code" New topic
Author

Accessing (session) attributes from JavaScript code

Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
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

Joined: Feb 26, 2005
Posts: 2053
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

Joined: Jan 10, 2002
Posts: 61106
    
  66

Please see this this article to understand how JSPs work.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

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

Joined: Nov 12, 2008
Posts: 757
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

Joined: Jan 10, 2002
Posts: 61106
    
  66

Optional? What do you mean by that?

To access the server, you submit the page or use Ajax.
Treimin Clark
Ranch Hand

Joined: Nov 12, 2008
Posts: 757
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Accessing (session) attributes from JavaScript code