<<< JSP Interview Questions and Answers >>>





JSP - Questions & Answers

Here is the list of JSP Interview Questions. The answers are short and to the point.These questions are frequently asked by the recruiters. So we try our best to provide you the JSP interview questions. A list of frequently asked JSP interview questions and answers are given below.

«« | 1 2 3 4 5 | »»

JSP: Java Interview Questions

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 :

  1. Extension to Servlet
  2. Easy to maintain
  3. 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 :

  1. Translation
  2. Compilation
  3. Classloading
  4. Instantiation
  5. Initialization
  6. Reqeust processing
  7. Destroy


4) What are the life cycle methods of JSP?

Ans :The life-cycle methods of a JSP are :

  1. jspInit()
  2. jspService()
  3. jspDestroy()


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 :

  1. <%@ page ... %> : Defines page-dependent attributes
  2. <%@ include ... %> Includes a file during the translation phase.
  3. <%@ taglib ... %> Declares a tag library, containing custom actions, used in the page.


«« | 1 2 3 4 5 | »»