JSP Interview Question and Answer

Connect with


There are so many questions in JSP but usually in the interview process few questions which is being asked frequently. Due to time constraint , Interviewer not get chance to ask more, as they start from core java and ask more questions from core java. As soon as reaches on JSP they face time crunch not able to asked more. But sometimes, they can focus more practical sort of questions, specially if they have more work on web component or server side component.

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 says 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 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 deployment directory and container will load the new JSP page, so remember do this style while development not for production. We don’t need to compile our project code or restart server whereas if we make change in servlet code, we need to build the complete project again and deploy it.

What are the JSP implicit objects ?

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

[table “” not found /]

Can we define a class in a JSP Page?

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 *