Which statement about jspInit() are true?
-
It has access to a ServletConfig
-
It has access to a ServeletContext
-
It is only called once
-
It can be overridden
The jspInit() method is called once during JSP initialization, has access to both ServletConfig and ServletContext (via config.getServletContext()), and can be overridden like other JSP lifecycle methods. All four statements are true.
jspInit() is the JSP-page analog of a servlet's init() method, called by the container exactly once when the JSP's generated servlet instance is initialized (before it handles its first request), just like _jspService()/destroy correspond to service()/destroy(). Being generated as part of a servlet class, it has full access to ServletConfig (via getServletConfig()) and ServletContext (via getServletContext()). It has a default no-op implementation but is explicitly designed to be overridden by the JSP author to perform one-time setup (e.g., acquiring resources). All four statements are accurate per the JSP specification, so marking all of them correct is right.