• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

What should a Servlet do if its loading a resource on load time that is taking time

 
Greenhorn
Posts: 17
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assume that resource loading takes 2 minutes and we need to handle the situation when a request comes at that stage. I doubt a Servlet should be throwing UnavailableException in the subject case.
 
Greenhorn
Posts: 16
Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding Caching logic in servlet for requested data. This might help on subsequent requests.
 
Saloon Keeper
Posts: 7389
170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Move that initialization code to a ServletContextListener - the web app won't accept request until it is run, so you won't have this problem.
 
Ranch Hand
Posts: 78
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can make your servlet to load the resource at the start up itself by using <load-on-startup>1</load-on-startup>. this will load the resource at the time of the servlet context creation (way before any requests)
 
Yasir Karim
Greenhorn
Posts: 17
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone.
When should a Servlet be throwing UnavailableException then?
 
Avinash Ga
Ranch Hand
Posts: 78
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yasir Karim wrote:Thanks everyone.
When should a Servlet be throwing UnavailableException then?



The case in which your application tier is down, and the servlet is unable to process the request without application tier the servlet can throw UnAvailableException. UnAvailableException is thrown to indicate the client code to say "Something Fishy" in the request processing. so that client can take corrective action. if there are now corrective actions then the client is let to have a time out.

Best Wishes
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic