Servlet


Explain the methods used for session tracking.

Following answer is applicable irrespective of the language and platform used. Before we enter into session tracking, following things should be understood. What is a session? A session is a conversion between the server and a client. A conversion consists series of continuous request and response. Why should a session be maintained? When there is a series of continuous [...]

FAQ Category: Servlet.

What happens if you call destroy() from init() in java servlet?

destroy() gets executed and the initialization process continues. It is a trick question in servlets interview. In java servlet, destroy() is not supposed to be called by the programmer. But, if it is invoked, it gets executed. The implicit question is, will the servlet get destroyed? No, it will not. destroy() method is not supposed to [...]

FAQ Category: Servlet.

How to avoid IllegalStateException in java servlet?

The root cause of IllegalStateException exception is a java servlet is attempting to write to the output stream (response) after the response has been committed. It is always better to ensure that no content is added to the response after the forward or redirect is done to avoid IllegalStateException. It can be done by including a [...]

FAQ Category: Servlet.

What is servlet mapping?

Servlet mapping specifies the web server which java servlet should be invoked for a given url. It maps url patterns to servlet and it is given in the web deployment descriptor web.xml. servlet-mapping has two child tags, url-pattern and servlet-name. url-pattern specifies the type of urls for which, the servlet given in servlet-name should be [...]

FAQ Category: Servlet.

Difference between HttpServlet and GenericServlet

javax.servlet.GenericServlet Signature: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable GenericServlet defines a generic, protocol-independent servlet. GenericServlet gives a blueprint and makes writing servlet easier. GenericServlet provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface. GenericServlet implements the log method, declared in the ServletContext interface. To write a generic servlet, [...]

FAQ Category: Servlet.

What is preinitialization of a java servlet?

In the java servlet life cycle, the first phase is called ‘Creation and intialization’. The java servlet container first creates the servlet instance and then executes the init() method. This initialization can be done in three ways. The default way is that, the java servlet is initialized when the servlet is called for the first time. [...]

FAQ Category: Servlet.

Servlet


Java FAQ by Category

Java FAQ Highlights

Recent Java FAQ