Let's learn java programming language with easy steps

Sunday, 11 March 2018

JSP Interview Questions and Answers

Interview Questions and Answers on JSP

JSP Interview Questions and Answers

Here we are gonna to discuss some basic and important JSP interview questions and answers. JSP is the most important topic for advance java interviews.

So let's start frequently asked java jsp interview questions.

(1) What is JSP?

JSP is known as 'Java Server Pages'. JSP is a server-side programming language which is used to create dynamic web-pages just like servlet technology. We can use jsp for making web project. In other words, by using JSP technology we can create attractive websites.

(2) Is JSP extension of Servlet?

Yes, Jsp is an extension of servlet technology.

(3) JSP page internally converted into servlet, true of false?

Yes, It is 100% true. Jsp pages internally converts into servlet.

(4) What is life-cycle of jsp?

Jsp life-cycle given below.
  • JSP page translation : Jsp page translate into servlet.
  • JSP page compilation: After translated into servlet, servlet compilation will be performed.
  • Classloading: By the help of classloader .class file of servlet will load.
  • Instantiation of Servlet: Object of servlet will create.
  • Initialization: Container will call jspInit() method only once in this phase.
  • Request Processing : Container will call -jspService() method for each request.
  • Destroy: In the last phase, Container will call jspDestroy() method.

(5) How many life-cycle methods are of jsp?

There are 3 life-cyle methods of jsp.

  1. jspInit() method.
  2. _jspService(ServletRequest  req, ServletResponse res) method.
  3. jspDestroy() method.

(6) How many implicit objects in jsp?

there are 9 implicit objects in jsp which is given below.

  1. out
  2. request
  3. response
  4. session
  5. config
  6. page
  7. exception
  8. application
  9. pageContext

(7) How to dissable session in jsp?

We can dissable session in jsp by using <% @ page session = "false" %>.

(8) Define all scripting elements in jsp?

1) Scriptlet Tag

By using scriptlet tag we can easily execute java source code in jsp file.

Syntax :

<% java code %>

2) Expression Tag 

By using expression tag we can easily get the value of any variables and methods.

Syntax :

<%= statement %>

3) Declaration Tag

Declaration tag is used to declare the variables and methods.

Syntax :

<%! declaration of variable and method %>

(9) Define all the directives in jsp?

There are 3 kinds of directives.

Jsp directive is responsible how to convert jsp page into servlet.

  1. Page Directive.
  2. Include Directive.
  3. Taglib Directive.

(10) How to declare jsp directive?

The syntax is used to declaring jsp directive,

<%@ directive attribute = "value" %>

for example : <%@ page import = "java.util.date" %>

(11) Write some attribute of jsp page directive.

There are some page directive attribute given below.
  • import
  • extends
  • contentType
  • pageEncoding
  • errorPage
  • isErrorPage
  • session
  • autoFlush
  • buffer
  • language
  • info
  • isThreadSafe
  • isELIgnored

(12) How to insert a comment in jsp page?

We can insert comment in jsp page by using  <% - jsp comment -%>.

(13) Difference between include directive and include action.

There are some differences between include directive and include action which is given below.

Include Directive
  • Include directive is better for static pages.
  • Include directive includes the original page of the content.
  • At the page translation time, It includes the content.

Include Action
  • Include directive is better for dynamic pages.
  • Include directive does not include original content.
  • At the time of a request, It includes the content.

(14) Is that mandatory to configure jsp file in web.xml file?

No, It is optional. We can run web application without configuration of jsp file in web.xml file.

(15) What is the difference between JSP and Servlet?

There are many differences between JSP and Servlet.

JSP(Java Server Pages)
  • JSP is easy to learn.
  • JSP provides some predefine tags such scriptlet tag, custom tag, expression tag, etc.
  • There is no need to configuration of jsp file in web.xml file.
  • Both presentation and business logic are separated in jsp.
  • There is no need to recompile and redeploy of jsp file if we modify any jsp file.
  • JSP provides certain implicit objects.

  • Servlet is not easy to learn.
  • Servlet does not provide any tags.
  • We have to configure servlet in web.xml file.
  • Both presentation and business logic are not separated in servlet.
  • If we modify and servlet then we have to recompile and redeploy the project.
  • Servlet does not provide implicit objects.

(16) What is expression language?

Expression language provides simple and easy to access the data from implicit objects and bean.

(17) What is JSTL?

JSTL stands for JSP standard tag library which is the collection of some useful core tags which make the software development easy and fast.

Visit : Servlet Interview questions and answers.
          OOPS Interview questions and answers.

I hope, this java jsp interview questions and answers will help you in java interviews.



Post a Comment

Facebook Page Likes

Follow javatutorial95 on Google+

Follow javatutorial95 on twitter

Popular Posts