JSP Interview Question and Answer

Connect with

JSP Interview Questions and AnswesrJSP interview questions and answers for different levels of JSP Java Interview, JSTL tags, jsp implicit variables.

About JSP interview questions

There are so many questions in JSP but usually, in the interview process, few questions are being asked frequently. Due to time constraints, Interviewers do not get a chance to ask more, as they start from core java and ask more questions from core java. As soon as reach JSP they face time crunch not able to ask more. But sometimes, they can focus on more practical sort of questions, especially if they have more work on web component or server side component. In MVC Architecture, V (View) plays an important role in the application.

What is JSP ?

JSP stands for Java Server Pages. JSP is java server side technology to create dynamic web pages. JSP is extension of Servlet technology to help developers create dynamic pages with HTML like syntax.

In MVC JSP used as a View, which says separation of business logic and presentation logic. Best practices say we should put only presentation logic not business logic. We can create user views in servlet also but the code will become very ugly and error prone. We can notice, most of the elements in web page is static, so JSP page is more suitable for web pages. JSP scripting elements can be used for writing java code in JSP pages but it’s best to avoid them and use JSP action elements, JSTL tags or custom tags to achieve the same functionalities.

One more benefit of JSP is that most of the containers support the hot deployment of JSP pages. Just make the required changes in the JSP page and replace the old page with the updated JSP page in the deployment directory and the container will load the new JSP page, so remember to do this style while development not for production. We don’t need to compile our project code or restart the server whereas if we make a change in servlet code, we need to build the complete project again and deploy it. This is one of the important things in JSP interview questons.

What are the JSP implicit objects ?

This is one of the most asked JSP interview questions during the JSP interview. There are 9 implicit objects by default as follows:

Following are the implicit Object and its Java Servlet Type as:

  1. implicit object outand its Java servlet type JspWriter
  2. implicit object requestand its Java servlet type HttpServletRequest
  3. implicit object responseand its Java servlet type HttpServletResponse
  4. implicit object config and its Java servlet type ServletConfig
  5. implicit object session and its Java servlet type HttpSession
  6. implicit object application and its Java servlet type ServletContext
  7. implicit object pageContext and its Java servlet type PageContext
  8. implicit object page and its Java servlet type Object
  9. implicit object exception and its Java servlet type Throwable

Can we define a class in a JSP Page?

Yes, although, it’s not a good practice to write class inside the JSP, but we can define a class inside a JSP Page as follows:

//static is better because Servlet is multi-threaded by default
private static class MyNestedClass { 
  private final int counter= 0;
  public int getCounter() {
    return counter;


    class Employee { 
        //this will go inside method body, so can't make it public

Connect with

2 thoughts on “JSP Interview Question and Answer”

  1. What’s up to all, how is everything, I think every one is
    getting more from this website, and your views are nice for novice people.

Leave a Comment

Your email address will not be published. Required fields are marked *