Lifecycle phases of JSP
There are 6 different lifecycle phases present for JSP namely:-
- Translation Phase
- Compilation Phase
- Instantiation / Object Creation Phase
- Initialization Phase
- Service Phase
- Destruction Phase
Lifecycle methods of JSP
There are 3 different lifecycle methods present for JSP namely:-
- jspInit() ====> @Override
- jspService(HttpServletRequest req, HttpServletResponse resp)
- jspDestroy() ===> @Override
Note:- JSP is used to give Presentation Logic.
Q) Why is JSP used to give Presentation Logic instead of Html?
Ans:- JSP is used to give Presentation Logic instead of HTML because of code simplification.
Contents of JSP:
1. Html
2. PageDirective:- default content of JSP.
3. Scriptlet:-It is the area which is used to write the Java Code File.
In case of JSP, Sciptlet is represented as <% %>
Ex:-
<% out.println(2*5) %>
4. Expression:- It is used to represent or print the Java Codes i.e Output.
In the case of JSP, Expression is represented as <%= %>
5. Declarative:- Data which are declared on an XML File.
web.xml ---> pom.xml[Maven] --- internet
Note:-
1. Most of the contents of JSP fit into _jspService().
2. The Naming convention followed by Apache Tomcat Server to store all the TranslatedServlet into the work folder of Apache Tomcat Server is [Filename_jsp.java].
Eg:-
If the Filename is Test.JSP, then TranslatedServlet name while sharing into the work folder is Test_jsp.java.
0 comments:
If you have any doubts,please let me know