Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why javascript is not getting the refreshed session attribute from JSP

 
Allok Srivastava
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64683
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic