| Author |
Session Attribute Values Fom JS
|
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1261
|
|
Have I been dreaming, totally crazy, or what? I was under the impression that if I had code in servlet like session.setAttribute("myVar"); Then in JS I could get that value with var v1 = "${myVar}" Am I wrong?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56543
|
|
You're not crazy, just a tad confused. That's not JavaScript, that's JSP. By the time the page gets to the browser, what it sees is:The substitution occurs on the server long before the HTML gets sent to the browser. P.S. Don't forget your semi-colons! [ December 19, 2008: Message edited by: Bear Bibeault ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1261
|
|
So if from my page I call a jQuery.getJSON("/myServlet") Then in that servlet do a session.setAttribute("myVar","1234"). Then back on the calling page call a function var v1 = "${myVar}" will fail. What I want to do is from my navigation page(based on a users log on) set a global value for that session.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56543
|
|
You didn't mention Ajax. Yeah, an Ajax call to another resource will have no effect on the page currently loaded. If you want the value of a session scoped variable, you'll need to pass it back as part of the JSON data.
|
 |
 |
|
|
subject: Session Attribute Values Fom JS
|
|
|