150+ Advanced Java Servlet API Interview Questions 2020-2021 - 1

Question: 1

What is URL rewriting?

It’s based on the concept of attaching a unique ID (which is generated by the server) in the URL of response from the server. So the server attaches this unique in each URL. When the client sends a requests it sends back this ID with the request also which helps the server to identify the client uniquely.

Question: 2

What are include directives?

The include directive informs the JSP engine to include the content of the resource in the current JSP page. Below is the syntax for include statement.

<%@ include file = “Filename” %>

Below is a code snippet which shows include directive in action

<html>

<head>

<title>Directives in action</title>

</head>

<%@ include file = “/ companyname.html” %>

<body><h1>Directive in action </h1>

</body>

</html>

Question: 3

What are the objects that are received when a servlet accepts a call from client?

The objects are ServletRequest and ServletResponse. The ServletRequest encapsulates the communication from the client to the server.

While ServletResponse encapsulates the communication from the servlet back to the client.

Question: 4

How does JSP engines instantiate tag handler classes instances?

JSP engines will always instantiate a new tag handler instance every time a tag is encountered in a JSP page.

A pool of tag instances are maintained and reusing them where possible. When a tag is encountered, the JSP engine will try to find a Tag instance that is not being used and use the same and then release it.

Related Questions
Recent Articles
Trending Posts

REGISTER TO GET FREE UPDATES