• 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

Action class being called only once in ajax

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

I am new to AJAX. I am using struts1.1
I have a text box 'PerBox'. when i enter some value in the textbox, onchange event calls my ajaxfunction. I call my struts action class and in the action class i set the response which gets printed on the jsp.

My problem is that my action class is being called only once. why so?

here is my jsp page:

my action class:


The system out statement is getting printed only on first call. On consecutive calls it is not getting printed. Also, the response is being taken from cache, since even if i change the value in my action class it shows up the previous value.

Thanks.

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you setting up the page on the server NOT to cache the page? You need to set the correct headers with the response.

GET requests are meant to be cached. It makes surfing the net a lot faster.

Eric
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have four options out here,

1. Use an Ajax library that takes care of such problems - my Favorite Jquery.
2. As Eric suggested set up the page for no-cache - you'll need to look at the headers for this.
3. Use the age old trick of generating a random parameter and appending it as part of your get request.
4. Since your request is not idempotent anyways - why not make a POST request.
 
Deeps Mistry
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sam Mercs wrote:You have four options out here,

1. Use an Ajax library that takes care of such problems - my Favorite Jquery.
2. As Eric suggested set up the page for no-cache - you'll need to look at the headers for this.
3. Use the age old trick of generating a random parameter and appending it as part of your get request.
4. Since your request is not idempotent anyways - why not make a POST request.



Hey thanks a lot Sam and Eric for your help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic