Machine-translated by Google. Questions are authored in English.
Top

Discussion

When a servlet cannot be instantiated by the servlet container, which exception is thrown to the servlet container methods such as init() or service() ?

  • A.InstantiationException
  • B.ServletInitializationException
  • C.IllegalStateException
  • D.None of these

Answer: D

The answer is None of these.

In the Servlet API, the life-cycle methods signal failure with ServletException and its subclass UnavailableException, which tells the container that the servlet cannot be put into service, temporarily or permanently. Neither is offered.

InstantiationException is a general Java reflection exception raised when a class cannot be instantiated; it is not what init() or service() throw. ServletInitializationException is not a class in the Servlet API. IllegalStateException is thrown when a method is called at the wrong time, for example sending a redirect after the response has been committed.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.