JSP Interview Questions and Answers For Beginners [2022]

The concepts of various computer science fields hold importance in the technical interviews, and one such topic is JavaServer Pages (JSP). Here is a chance to get acquainted with the commonly asked questions on JSP. The JSP questions and answers are formulated according to the current trend of questions seen in the technical interview, and also it will help you in your last-minute preparation for the topic.

The JSP interview questions will cover the very basic concepts later, proceeding to some higher level of questions about JavaServer Pages.

JSP Interview Questions & Answers

1. What is JSP?

  • JavaServer Pages is a technology employed to develop web pages that aid dynamic content. It is a server-side programming language exploited by developers to insert java code in HTML files.

2. How do the JSP tags start and end?

  • The JSP tags generally start with <% and end with %>

3. What is the JavaServer Page component?

  • The JavaServer page is the java servlet that acts as the user interface for java based applications.

4. Why do developers prefer to write JSP text files?

  • The JSP text files combine all the available files of HTML, XML code, and elements and the previously rooted java code.

5. Why are JSP tags used?

  • JSP tags are utilized to procure information from the database, get through JavaBeans components, and share requests between pages.

6. What are the advantages of JSP over the Common Gateway Interface(CGI)?

  • The advantages of JSP over CGI are quite clear.
  1. Performance is better than CGI as there is no need to create an additional file, which is a problem in CGI.
  2. JSP has admission to all robust APIs
  3. JSP can be used vividly for most simple applications to most complex applications.

7. What are the advantages of JSP over ASP?

  • The dynamic part of JSP is written in java and hence proves to be easier and powerful. It can effortlessly port itself to any operating system.

8. What is include directive and include action?

  • Include directive and include action, as the name suggests, is the method used to include the result of some other page to the required destination.

9. What is the scope of <jsp.useBean> tag?

  • The scope values of the given tag are page, request, application, and session.

10. What are JSP implicit objects? Define briefly.

  • The JSP implicit objects are established by the servlet while converting JSP to the servlet container. Nine JSP implicit objects can be used in a JSP page directly. Two implicit items are part of the _jspService() method argument. Seven out of nine implicit objects are asserted as a local variable of _jspService().

11. What do you know about one of the implicit objects called session objects?

  • It is the instance of java.servlet.HttpSession execution. Upon requesting a JSP page, the container automatically prepares a session in the service method. But it creates sessions according to the requirement of the business logic. We can tackle when we don’t want to create a session process as it is heavyweight and cannot be accommodated everywhere.

12. What does a typical JSP directive appear like?

     -The typical JSP directive is written in the form of <% directive attribute =”value”%>.

13. What do you understand by the JSP page directive?

  • JSP page directives apply to the whole page and offer a number of attributes in one single page. It is also possible to have numerous page directives applied to a single JSP page.

14. Name a few attributes under the JSP page directive.

  • Below is the list of few attributes of the JSP page directive briefly explained.
  1. Import attribute:- Used to guide containers to import java classes and interfaces and produce servlet side by side. It is also one of the most used attributes.
  2. Extends attribute:- It defines the superclass produced by servlet code, and it can be used when one has expanded HttpServlet.

<% page extends=”org.apache.jasper.runtime.HttpJspBase” %>

     3. Language attribute:- It is recognized to stipulate the scripting language. It extends its support to scripting languages like C++ and PHP.

15. What is the role of JSP include directive?

  • It includes the content of other pages to the JSP page. It is used to form templates and further breaks down the page into different elements like header, footer, etc. The file can be of any type like HTML, XML, etc.

                                <%@ include file=”test.html” %>

Read: Java Developer Salary in India

16. How to handle exceptions in JSP?

  • The exceptions can be handled in two ways either By errorPage and isErrorPage attributes of page directive or By <error-page> element in web.xml file.

17. How to forward a request to JSP servlet?

  • To forward the JSP servlet request, one can use the “forward” tag before that one needs to send the URL pattern of the servlet.

18. Name the consisting blocks of JSP literals.

  • Boolean
  • Integer
  • Floating point
  • Null
  • String

19. Give one difference between ServletContext and PageContext.

  • The information about the container is provided by ServletContext, while PageContext gives the request information.

20. What is JSTL?

  • It is a JSP library that has predefined tags and soothes the process of developing JavaServlet Page.

21. What are the tags available in JSTL?

  • There are five tags available in JSTL 
  1. Core tags
  2. Function tags
  3. SQL tags
  4. XML tags
  5. Internationalization tags

22. How do you include the static files in JSP?

  • JSP includes directives that are used to deploy static files in JSP. In this way, the inclusion process is performed only once as the resources are included, but before that, the URL must be given for file.

23. Give a brief about its lifecycle methods?

  • jsplnit(): Initially, the method is called to initialize servlet and is called only for once.

_jspService(): The container calls this method and then processes the request accordingly.

jspDestroy(): Before the demolition of instance, this method is called.

24. Why is there “_” before _jspService, but nothing precedes the rest lifecycle methods?

  • Before this method, the underscore shows the lack of overriding in this particular method, while the other two methods can easily be overridden.

25. Can we override the static methods?

  • No, because we can only declare static methods in the subclass, polymorphism is according to the definition.

Also Read: Java Interview Questions

Learn Software development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs, or Masters Programs to fast-track your career.


The JSP interview questions have a wide range of variety, and the above JSP questions touch every such concept. To get a better hold on the concept try the snippets on a code editor and feel the difference. 

If you’re interested to learn more about Java, full-stack development, check out upGrad & IIIT-B’s Executive PG Program in Full-stack Software Development which is designed for working professionals and offers 500+ hours of rigorous training, 9+ projects, and assignments, IIIT-B Alumni status, practical hands-on capstone projects & job assistance with top firms.

Become a Full Stack Developer

Leave a comment

Your email address will not be published.

Let’s do it!
No, thanks.