JSP Interview Questions and Answers

Last updated on Mar 08, 2022
  • Share
JSP Interview Questions

JavaServer Pages or JSP is a software-based technology that helps developers in creating dynamically generated web pages based on XML or HTML. It uses servlet containers, small programs to control the content and appearance of the web page. JSP technology can also be used to share information across pages using a response and request objects. With the help of JavaServer Page, you can easily access JavaBeans objects and make a separation in the web applications as per the business logic. To know more about JavaServer Page, we are mentioning some of the JSP Interview Questions are useful for all types of readers.

Most Frequently Asked JSP Interview Questions

Here in this article, we will be listing frequently asked JSP Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.

Q11. Explain the JSP implicit objects?
Answer

Created by JSP Engine during translation phase, while translating JSP to Servlet, JSP implicit objects are crafted inside service method and can be used directly within scriptlet without initializing and declaring them. In JSP, a total number of 9 implicit objects are available as following, Out, Request, Response, Session, Application, Exception, Page, pageContext, and config.

Q12. How we can include the result of another page in JSP?
Answer

So many mechanisms are available through which the results of another page can be included in JSP.

There of primary mechanisms used by developers are

  • Include directive
  • jsp:include element
  • Codas and preludes
Q13. List the different scope values for the <jsp:useBean> tag in JSP?
Answer

This tag is required to use any Java object present in the JSP page.

The scope values for tag are as following: application, request, page, session, etc.

Q14. What is <jsp:useBean> in JSP?
Answer

This action tag is used to instantiate or locate a bean class. Depending on the scope, it doesn’t create the bean if the bean object of the Bean class is already created. This JSP action tag has five attributes, which includes Id, Scope, Class, Type and Bean Name.

Q15. What are the difference between ServletContext and PageContext?
Answer

In JSP, the ServletContext shares information about the container in which the servlet is running in. This can be set up in the web application descriptor. There can be only one v ServletContext per web application. Compared to this, the PageContext gives the servlet information about the request that it is currently managing and contains information about the request, the response object, the session, and also a reference to the ServletContext of the web application.

Q16. What is the differences between the JSP custom tags and java beans?
Answer
  • Custom tags are used to manipulate the JSP content, whereas Java beans can’t be manipulated.
  • Java beans are easy to implement compared to custom tags which are tedious to implement.
  • Custom tags contain self-contained behaviour, but Java beans are defined in one servlet and it is used in the JSP page or different servlet.
Q17. What do you mean by JSTL?
Answer
The JSP Standard Tag Library or JSTL is a set of tags created to simplify the JSP development. The JSTL tags help in fast development, code reusability and eliminate the required use of scriptlet tags.
Q18. List all tags that are provided in JSTL?
Answer

Based on function, JSTL tags are categorized into five types, which are Core Tags, Formatting and Localisation Tags, SQL Tags, XML Tags and Functions Tags.

Q19. What are the steps for creating custom tags in JSP?
Answer

To create a custom tag in JSP, use the following steps.

  • Create the tag handler class first
  • Then, create the TLD file
  • Finally, create the JSP file
Q20. How we can configure init params in JSP?
Answer

Developers can configure init params in JSP similar to the servlet in the web.xml file. We have to configure JSP init-params with servlet and servlet-mapping element. Put the JSP page location in the JSP-file element.

Development History

Developed and released by Sun Microsystems in 1999, JSP is similar to ASP and PHP, it uses the Java programming language for its workability. A compatible web server with a servlet container, such as Jetty or Apache Tomcat, is required to run JSP.

The program actually runs with a .jsp filename extension and application/JSP internet media type. The latest version of JSP is its 2.3 version which runs with a 4.0 version of servlet compatibility.

These JSP interview questions are specially curated highly experienced industry professionals to help candidates in their future job success.

Advantages of JSP
  • Significant performance due to the allowance of embedding Dynamic Elements in HTML Pages.
  • Easily combined with static templates, XML or HTML fragments, with code that generate dynamic contents.
  • Web authors cab change or edit the fixed template portions of web pages without affecting the application logic.
  • It offers a wide range of API to highly increase the result-oriented functionality.
Reviewed and verified by Best Interview Question
Best Interview Question

With our 10+ experience in PHP, MySQL, React, Python & more our technical consulting firm has received the privilege of working with top projects, 100 and still counting. Our team of 25+ is skilled in...