Latest Servlet Interview Questions and Answers

Read Top Servlet Interview Questions and Answers Experienced, Freshers for Job Interview Quiz with Solutions.

What is a Servlet?

A servlet is a Java technology and it is managed by a container called servlet engine. It generates dynamic content and interacts with client through Request and Response.

Why servlet is mostly used?

Servlets are mostly used because they are platform-independent Java classes and are compiled to platform-neutral byte code. Java byte code can be loaded dynamically into and run by java enabled web server.

What is called servlet container?

A servlet container is a part of Web server that provides network services depends on request and response are sent, MIME based requests and responses. It contains and manages servlets through their life cycle.

What is a filter?

A filter is nothing but a piece of code which can be reusable that will be transforming the content of HTTP requests, response and header information.

How can we refresh automatically when new data has entered the database?

Refresh in Client side and Server Push can be performed to refresh automatically when new data is entered into the database.

What is called a session?

A session is an object which is used by a servlet and it is used to track user interaction with a web application across multiple HTTP requests.

What is servlet mapping?

Servlet Mapping is an association mapping between servlet and a URL pattern. This is used to map servlets with the requests.

What is a servlet context?

Servlet context contains servlet view of Web application in which servlet will be running. By using the context,

  • Log events

  • Obtain URL references to resources

  • Set and Store attributes

Which interface should be implemented by all servlets?

Servlet interface should be implemented by all servlets.

What is life cycle of Servlet?

Following is life cycle of Servlet:

  • Loaded

  • Initialized

  • Destroy

  • Unloaded

What is the difference between Servlet Request and Servlet Context when calling a Request Dispatcher?

Relative URL can be called when Servlet Request is used and Relative URL is not used when using Servlet Context.

What are the features added in Servlet 2.5?

Following are the features added in Servlet 2.5:

  • Dependency on J2SE 5.0

  • Support for annotations

  • Loading the class

  • Several web.xml

  • Removed restrictions

  • Edge case clarifications

When servlet is loaded?

A servlet can be loaded when:

  • First request is made

  • Auto loading and Server starts up

  • There is a single instance that answers all requests concurrently which  saves memory

  • Administrator manually loads.

When Servlet is unloaded?

A servlet is unloaded when:

  • Server shuts down

  • Administrator manually unloads

What are the supporting protocol by HttpServlet ?

HttpServlet supports only HTTP and HTTPS protocol.


Popular posts from this blog

TOP Agile Testing Interview Questions and Answers

Latest Agile Testing Interview Questions and Answers

Most Asked ADO.NET Interview Questions and Answers