Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Asynchronous servlets

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JEE6 there is support for asynchronous servlets. This means that the servlet can be called asynchronously.

I am struggling to understand how the asynchronous servlet will work in practical scenario.
e.g
1. User A makes a servlet call using a url say http:/www.example.com/app/asyn
2. The servlet returns immediately while spawning a new thread to process the servlet request
3. User A then moves to another screen
4. In the meanwhile the servlet processing finishes, then how would this response be sent to client.

If somebody can explain this it will be very helpful
 
Saloon Keeper
Posts: 7063
164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, that's not how it works. If the user indeed moves away from the page then the response has nowhere to go. No, the asynchronicity is merely in the servlet code. This may help: http://blogs.oracle.com/enterprisetechtips/entry/asynchronous_support_in_servlet_3
 
Pankaj Kumarkk
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. It was useful.
So
essentially asynchronous servlet is useful as it helps in reusing the servlet thread when a request is being processed in a long running process.
 
Marshal
Posts: 26749
81
Eclipse IDE Firefox Browser MySQL Database
  • 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 it's just a bookkeeping exercise. Instead of doing your long-running processing in the servlet's thread, you do it in some other thread instead. Nothing else changes; the client still has to wait until your long-running processing finishes before it gets the response, for example. Frankly it's difficult for me to see what problem this feature was intended to solve or why I should use it.
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some of the uses are:
- asynchronous EJB method invocation
- chat
- RESTful web services
- quality of service

Advantages:
- improves scalability
- not blocking container threads
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic