Set - 4

Question 1 :

What is the difference between directive include and jsp include?

Answer :

<%@ include> : Used to include static resources during translation time. : Used to include dynamic content or static content during runtime.

Question 2 :

What is the difference between RequestDispatcher and sendRedirect?

Answer :

RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects.

Question 3 :

How does JSP handle runtime exceptions?

Answer :

Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting of a JSP.

Question 4 :

How can my application get to know when a HttpSession is removed?

Answer :

Define a Class HttpSessionNotifier which implements HttpSessionBindingListener and implement the functionality what you need in valueUnbound() method.
Create an instance of that class and put that instance in HttpSession.

Question 5 :

What Class.forName will do while loading drivers?

Answer :

It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.