Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

help in asynchronous context

 
Ranch Hand
Posts: 89
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,


is asynchronous context in servlet 3.0 different from ajax? Or it is the same?

ajax has callbacks to change a specific position in the browser.

how to create callbacks for asynchronous context?


Thanks!
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alexander Sales wrote: is asynchronous context in servlet 3.0 different from ajax? Or it is the same?


AsyncContext is entirely different from ajax. First read this article to understand what it is for and how it works. See more examples of how it works here and here.
 
Alexander Sales
Ranch Hand
Posts: 89
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the concept of Asynchronous context is to create a back-end server processing and the client won't have to wait for the loading?...

 
Piyush Joshi
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Client will have to wait for the asynchronous process to complete. When the async process will be complete then only the response will be committed.
Actually this concept of asynchronous processing is not with respect to client. For the client it will take the same time to complete the request.

Think it in terms of server performance. Server has a limited number of threads in thread pool which can serve a client's request. If a request is taking a long time to complete then for that duration the thread will be blocked. This reduces the efficiency of server. Imagine a scenario where all the threads in the thread-pool are blocked. Now if a new request comes then it will have to wait for the existing threads to complete processing. This is not acceptable.

But in asynchronous processing of the request the thread which is serving the client request can return to the container without committing the response. So this thread doesn't have to wait for the lengthy operation to complete. It will put the request in async mode and then start the lengthy operation in a background thread, and return to container, without waiting for that operation to complete. This thread will now become available to serve other client requests.

Remember in async mode returning to the container does not commit the response. In fact its in the hands of background thread to commit the response by calling asyncContext.complete() or any of the dispatch() methods.

So async processing does not reduce the request processing time, but it increases the average number of threads available to handle any request.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic