aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Can we call System.exit(0) in service method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Can we call System.exit(0) in service method" Watch "Can we call System.exit(0) in service method" New topic
Author

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

Pandu Rangam
Greenhorn

Joined: Dec 08, 2006
Posts: 24
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?


SCJP 1.4,<br />SCWCD 1.4
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42611
    
  65
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.


Ping & DNS - my free Android networking tools app
 
Consider Paul's rocket mass heater.
 
subject: Can we call System.exit(0) in service method