• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Exception in Servlet Init()

 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

If a servlet throws
- ServletException
- More specific subclass , UnavialableException
in its init() method , then what are course of actions web-container takes :
- Immediately
- And for future requests for this servlet
Plz clarify
Thankx in advance
------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See Section 2.3.2.1 of the Servlet spec (p.24)
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx Tim

yes i been following spec 2.3.2.1 , but i am not very clear about what it wanna say .
Like if my servlet throws ServletException randomly in init() as:
random = new Random();
if(random.nextBoolean())
throw new ServletException("custom message");

Than for the first request , it shows servlet exception with custom message ,
all further requests are replied with :
"The requested resource (/exceptionapp/servlet/Serve) is not available"
And if my servlet throws UnavailableException randomly in init() as:
random = new Random();
if(random.nextBoolean())
throw new UnavailableException("custom message");

Than for all requests to this servlet are responded with
"The requested resource (/exceptionapp/servlet/Serve) is not available"

But one part of spec2.3.2.1 says :
...A new instance may be instantiated and initialized by the container after a
failed initialization....
So what are those conditions , under which container will try make new instance for further requests , even after one failed initilization ?

------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anytime the specs say "May", this means that it is implementation specific. Check the Doc's for your Server to determine what it will do or setup some test servlets and see.
------------------
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankx Carl


...or setup some test servlets and see...



So what you think , i was *guessing* those outputs?
I did setup those servlets , and then only posted my question

------------------
Gagan (/^_^\) SCJP2
Die-hard JavaMonk -- little Java a day , keeps u going .
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic