1) What is JSP?
Ans :JSP stands for Java Server Pages.JSP is a server side technology to help developers to create dynamic pages with HTML like syntax. The jsp pages are easier to maintain than servlet because we can separate designing and development. It provides some additional features such as Expression Language, Custom Tag etc.
2) What are advantages of using JSP?
Ans : The advantages of using JSP are :
- Extension to Servlet
- Easy to maintain
- Less code than Servlet
Extension to Servlet : JSP technology is the extension to servlet technology. We can use all the features of servlet in JSP. In addition to, we can use implicit objects, predefined tags, expression language and Custom tags in JSP, that makes JSP development easy.
Easy to maintain :JSP can be easily managed because we can easily separate our business logic with presentation logic. In servlet technology, we mix our business logic with the presentation logic.
Less code than Servlet : In JSP, we can use a lot of tags such as action tags, jstl, custom tags etc. that reduces the code. Moreover, we can use EL, implicit objects etc.
3) What is the life-cycle of JSP?
Ans : The life-cycle of JSP is :
- Reqeust processing
4) What are the life cycle methods of JSP?
Ans :The life-cycle methods of a JSP are :
5) What is the jspInit() method?
Ans :This method is invoked by the container only once when a JSP page is initialized. It can be overridden by a page author to initialize resources such as database and network connections, and to allow a JSP page to read persistent configuration data.
6) What is the jspService() method?
Ans :This method takes the HttpServletRequest and HttpServletResponse objects as its arguments. A page author cannot override this method, as its implementation is provided by the container.
7) What is the jspDestroy() method?
Ans :This method is similar to the destroy() method of servlets. It can be overridden by a page author to perform any cleanup operation such as closing a database connection.
8) What are JSP declarations?
Ans : A declaration declares one or more variables or methods that you can use in Java code later in the JSP file. You must declare the variable or method before you use it in the JSP file.
9) What are JSP Directives?
Ans :A JSP directive affects the overall structure of the servlet class. It usually has the following form:
- <%@ directive attribute="value" %>
10) What are the types of directive tags?
Ans :The types of directive tags are :
- <%@ page ... %> : Defines page-dependent attributes
- <%@ include ... %> Includes a file during the translation phase.
- <%@ taglib ... %> Declares a tag library, containing custom actions, used in the page.