• 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
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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.
 
Bartender
Posts: 7645
178
  • 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
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic