• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help me on how to control servlet  RSS feed

 
Max Bean
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I don't want my servlet to load/start/run if the connection to database server is not satisfied, how can I do that?

Wouldn't it be dreamy to do that magic obstruction to servlet initialization?

Many thanks
Max
[ October 19, 2007: Message edited by: Maximilian Boonyoung ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't it be dreamy to do that magic obstruction to servlet initialization?

Your dream can come true: According to the javadocs of Servlet.init, the servlet will not be put into service if the init method throws a ServletException.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maximilian,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
UseRealWords

Abbreviations such as "u" or "ur" in
place of "you" and "you are" or "you're" confound language translation software making
it hard for our non-English speaking members to read your posts.
"plz" is not a word in the English language.

Again, welcome to JavaRanch and good luck with your question.
-Ben
 
Max Bean
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to say sorry for that bad word.

You mean I can override the init() method? If there are two of them, one without parameter and another one with SevletConfig as parameter, which one?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Maximilian Boonyoung:
I would like to say sorry for that bad word.

Then why not go back and change it?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean I can override the init() method? If there are two of them, one without parameter and another one with SevletConfig as parameter, which one?

If you read the javadocs of both init methods, it should become clear which one to override.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!