• 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

how to get refrance of a current executing thread of a servlet

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

In my application i am performing search functionality,the searched result i need to display into a jsp page.

But this functionality is taking some time to load a jsp page.so my requirement is to change label of the "search" button to "cancel " button after click on search .

And when i click on cancel the last search request should be canceled .the search request i am sending to servlet through ajax call.

So how i can cancel the current running thread of a servlet.

Regards,

Chandra Prakash
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I can see, for normal Http request simply pressing escape-key or browser's stop button, nullifies the previous request. So, why not in Ajax. I am not sure how are you implementing the Ajax functionality, but I assume you are using some framework like, JQuery, Prototype, ExtJS etc.. After a bit of Google search, I got to know that these libraries have an abort() like function to abort Ajax request request. You might want to look the source code, to know what is there exactly.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may be able to cancel the request as far as the client browser is concerned but the Thread executing the request on the server will NOT notice this until it tries to output to the response.

Therefore, you might have that long running Thread periodically send some text to the response and flush the output stream. This will get you an exception, aborting the long running process, because the socket has been closed.

It is much better practice to start a separate Thread for long running processes - see many many discussions on the Ranch of this problem.

Bill



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic