1. The JSP is coverted into a Servelet that extends HttpJspBase which is a tomcat implementation of the javax.servlet.http.HttpJspBase interface. This interface extends JspBase, Together these two interfaces have three JSP lifecycle methods, jspInit(), jspService() & jspDestroy(), Then from how does call to getServletConfig(), getServletContext() in the JSP's lifecycle methods or instance methods work, Where are these methods defined, i know the JSP gets converted to a servlet. How does a JSP inherit getServletContext() & getServletConfig methods from?
hi, i know i am not answering you fully but to make sure you have seen this point...
The servlet generated by the Jsp has an object pageContext which is of type PageContext and this object pageContext has the methods getServletConfig() and getServletContext() ...
Joined: Aug 05, 2006
Agreed but Am afraid,you don;t. Cause pageContext is a actually a local variable inside _jspService() and thats how it becomes a implicit object in JSP. The thing is how does jspInit() and jspDestroy() get access to getServletConfig() and getServletContext().
The JSP container creates a JSP page implementation class for each JSP page. The name of the JSP page implementation class is implementation dependent. The JSP Page implementation object belongs to an implementation-dependent named package. The package used may vary between one JSP and another, so minimal assumptions should be made. As of JSP 2.0, it is illegal to refer to any classes from the unnamed (a.k.a. default) package. This may result in a translation error on some containers,
The contract on the JSP page implementation class: 1 Implements HttpJspPage if the protocol is HTTP, or JspPage otherwise. 2 All of the methods in the Servlet interface are declared final. Additionally, it is the responsibility of the JSP page author that the provided superclass satisfies: 1 The service method of the servlet API invokes the _jspService method. 2 The init(ServletConfig) method stores the configuration, makes it available via getServletConfig, then invokes jspInit. 3 The destroy method invokes jspDestroy.
A JSP container may give a fatal translation error if it detects that the provided superclass does not satisfy these requirements, but most JSP containers will not check them.