JSP API
The JSP API consists of two packages:
- javax.servlet.jsp
- javax.servlet.jsp.tagext
javax.servlet.jsp package
The javax.servlet.jsp package has two interfaces
- JspPage
- HttpJspPage
The classes are as follows:
- JspWriter
- JspFactory
- JspEngineInfo
- PageContext
- JspError
- JspException
Note:– Acconding to jsp specification the servlet class which is generated from jsp page must be implements JspPage interface and HttpJspPage interface.
Methods of JspPage interface(javax.servlet.JspPage)
The JspPage interface provides the two life cycle method of JSP.
- public void jspInit(): It is invoked only once in life cycle of the JSP when client firstly request of any JSP page . It is used to perform initialization. This method is call from servlet Init() method.
- public void jspDestroy(): It is invoked only once in the life cycle of the JSP .This method is call from servlet Destroy() method .It is used to perform clean up operation.
The HttpJspPage interface(javax.servlet.HttpJspPage)
The HttpJspPage interface provides the one life cycle method of JSP. It extends the JspPage interface.
Method of HttpJspPage interface:
- public void _jspService(): It is invoked each time when request for the JSP page comes to the container. It is used to process the request. This method is call from servlet Service()method.
How jsp work
Step 1 :- Web Container translates JSP code into a servlet class source(.java) file.
Step 2:- Compiler compile .java file and generate .class file.
Step 3:– The classloader load .class file and Web Container creates an instance of that servlet class.
Step 4:- Web Container call the jspInit()method to initialized servlet.
Step 5:- Web Container creates thread and call the _jspService()method For each request.
Step 6:- When the Web Container removes the servlet instance from service, it calls the jspDestroy() method to perform any required clean up process.
hi mst hai bhai
LikeLike
Nice information
LikeLike