Which of the following servlet methods can return null? (Choose one.)
-
getInitParameterNames()
-
getInitParameter(String name)
-
getServletName()
-
getServletContext()
getInitParameter(String name) returns null if the requested parameter does not exist. The other methods (getInitParameterNames returns an Enumeration, getServletName returns a String, getServletContext returns a ServletContext) never return null.
getInitParameter(String name) looks up a named init parameter and returns null if no parameter with that name was configured for the servlet. The other methods listed always return a non-null value: getInitParameterNames() returns an (possibly empty) Enumeration, getServletName() returns the configured servlet name, and getServletContext() always returns the context object.