• 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

client could not get update session data

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to retrieve data and update a web page every few seconds. I had a problem to get updated session data from client side. I use a ajax call (in jsp file) to send request to struts action, which perform the request and saved java object data in the session. Then the jsp file (which sent request) use javascript to create a table dynamically, but the problem is that the javascript always get old session data, unless the jsp page is refresh, which is not wanted.

I have cleared the catch both in jsp file and in server side, and wondering what is the reason of the problem?

Thanks for the help!
 
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
When using Ajax the page doesn't access the server except though the Ajax request, so how could it possibly know anything about session data?

The only new data that the page gets is from the Ajax response.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh i see. Thank you for the clarification. I am looking at json (did not use it before), I am thinking to return json object (convert java object to json obj) to client side and use javascript to parse it. Is there any other better solution?
 
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
Better in what way?
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean in other way like using xml instead of json, I think they are not big difference between them, just the data format difference.

I got another problem, in struts 1, I usually handle the request and forward reponse to a jsp file , as result jsp file got a form. Now I use ajax to call the action, the action handle request and convert java object to json ( ), how could I get that from jsp file? As I know, strus only forward the action form to jsp file.

Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic