Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we call System.exit(0) in service method

 
Pandu Rangam
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
First of all thanks for your prompt replies on my previous posts.
My questions are
1) can we call System.exit(0) in servlet's life cycle methods (eg service)?
2) Can we call destroy explicitly from service method?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) can we call System.exit(0) in servlet's life cycle methods (eg service)?

What would be the point of that? You'd be trying to force the JVM to quit, and thus the servlet container to stop. That's why servers in a production settings run with a security manager enabled, which prohibits calls to System.exit (amongst other things).

2) Can we call destroy explicitly from service method?[/QB]

init and destroy are servlet lifecycle methods, which are called by the servlet container. You can call them, but you absolutely should not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic