• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why javascript is not getting the refreshed session attribute from JSP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have javascript function in A.jsp page, which will be called using setInterval to check for the session attribute which is being set by B.jsp page.
But when i check for the attribute value, it gives null in A.jsp page, bcoz, my java script couldn't able to pick up the refreshed session value.
What am i doing wrong, please help me to resolve this problem
Any help is highly appreciated.

Thanks
Smitha
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your session attribute is on the server. JavaScript executes on the client and has no access whatsoever to the session.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

it gives null in A.jsp page, bcoz,

Please use real words when posting to the forums. Abbreviations such as "bcoz" in place of "because" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Allok Srivastava
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,
but my javascript is itself in the JSP page.
Sample code as follows:
A.jsp


In A.jsp, my status attribute will allways return null, when i refresh the A.jsp page after executing B.jsp, it gives the proper result.
Please help me to solve this.

Thanks
Smitha
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The fact that the code is mixed in the same file doesn't change what Bear said.

The best way to get a handle on this is to get in the habit of looking at the HTML source of your pages (using your browser's view page source feature). This is what is created by JSP and passed to your browser.
Your JSP code and your Javascript code are interpreted on two different machines, at different times.
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic