JSP – Core Java Interview Questions

Modified Date:- Published Date:-

Categories: Others

Q.1. What are the different tags provided in JSTL?

 

Ans. There are 5 type of JSTL tags.

 

(i) core tags

(ii) sql tags

(iii) xml tags

(iv) internationalization tags

(v) functions tags

 

Q.2. How to disable session in JSP?

 

Ans. <%@ page session=“false” %>

 

Q.3. Explain the jspDestroy() method.

 

Ans. jspDestry() method is invoked from javax.servlet.jsp.JspPage interface whenever a JSP page is about to be destroyed. Servlets destroy methods can be easily overridden to perform cleanup, like when closing a database connection.

 

Q.4.  How is JSP better than Servlet technology?

 

Ans. JSP is a technology on the server’s side to make content generation simple. They are document-centric, whereas servlets are programs. A Java server page can contain fragments of Java program, which execute and instantiate Java classes. However, they occur inside an HTML template file. It provides the framework for the development of a Web Application.

 

Q.5. Why should we not configure JSP standard tags in web.xml?

 

Ans. We don’t need to configure JSP standard tags in web.xml because when container loads the web application and find TLD files, it automatically configures them to be used directly in the application JSP pages. We just need to include it in the JSP page using taglib directive.

 

Q.6. How will you use JSP EL in order to get the HTTP method name?

 

Ans. Using pageContext JSP EL implicit object you can get the request object reference and make use of the dot operator to retrieve the HTTP method name in the JSP page. The JSP EL code for this purpose will look like ${pageContext.request.method}.

 

Q.7. What are the differences between get and load methods?

 

Ans. The differences between get() and load() methods are given below.

 

No.

get()

load()

1)

Returns null if object is not found.

Throws ObjectNotFoundException if an object is not found.

2)

get() method always hit the database.

load() method doesn't hit the database.

3)

It returns a real object, not a proxy.

It returns a proxy object.

4)

It should be used if you are not sure about the existence of instance.

it should be used if you are sure that the instance exists.

 

Q.8. What are the life-cycle methods for a jsp?

 

Ans.

Methods

Description

public void jsplnit()

It is invoked only once, same as init method of servlet.

public void _jspservice(ServletRequest

request,ServletResponse)throws

ServletException, IOException

It is invoked at each request, same as service() method of servlet.

public void jspDestroy()

It is invoked only once, same as destroy() method of servlet.

 

Top articles
Global Perspectives: International Reactions to the Ayodhya Ram Mandir Verdict Published at:- Top Cyber Encounters Book Writers You Need to Know Published at:- Productivity Hacks: Managing Mobile Addiction in the Workplace Published at:- Hyundai Ioniq 5 EV Maintenance Guide: Keeping Your Electric Vehicle in Top Condition Published at:- A Complete Guide to Mastering the Private Mention Feature in WhatsApp Published at:- SUV Launch: A Comprehensive Guide to the Latest Models Published at:- Breaking News: Hero MotoCorp Holds Strong Position in April Rankings Published at:- Thoughtful Mother's Day Gift Ideas for 2024: Show Mom You Care Published at:- Stay Ahead of the Curve: The Definitive List of Top AI Tools for 2024 Published at:- The Link Between Man-Made Pollution and the Heatwaves: What You Need to Know Published at:- Dominate Social Interactions: Tips for Meta's AI Bot on Whatsapp and Instagram Published at:- Monsoon Marvels: Discovering the Beauty of Goa in 2024 Published at:- JSP – Core Java Interview Questions Published at:- Protect Your Indoor Plants: Strategies for Thriving Through Storms Published at:- NEET (BOTANY MCQs) Published at:- Why Ola Decided to Exit Google Maps: Insights into Their New Strategy Published at:- Business, Economy & Banking (MCQs) Published at:- Important Days and Events (MCQs) Published at:- Summits and Conferences (MCQs) Published at:- Books and Authors (MCQs) Published at:- Reports and Indices (MCQs) Published at:- NEET (BOTANY-Anatomy of flowering plants) MCQs Published at:-