Which statement about jspInit() are true?
-
It has access to a ServletConfig
-
It has access to a ServletContext
-
It is only called once
-
It can be overridden
The jspInit() method is called once when the JSP is first initialized, similar to servlet init(). It has access to both ServletConfig (getServletConfig()) and ServletContext (getServletContext()), and it can be overridden like any JSP method. All four statements are correct.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) It has access to a ServletConfig - This option is correct. The jspInit() method in JSP has access to a ServletConfig object, which provides information about the JSP's configuration settings.
Option B) It has access to a ServletContext - This option is correct. The jspInit() method in JSP also has access to a ServletContext object, which provides information about the JSP's execution environment.
Option C) It is only called once - This option is correct. The jspInit() method is called only once during the lifecycle of a JSP. It is called when the JSP is initialized or loaded for the first time.
Option D) It can be overridden - This option is correct. The jspInit() method can be overridden in a JSP's Java code. By overriding the jspInit() method, you can provide custom initialization logic for the JSP.
Based on the explanations above, all of the given options (A, B, C, and D) are true. Therefore, the correct answer is A, B, C, D.