What mechanisms are used by a Servlet Container to
maintain session information?
Cookies, URL rewriting, and HTTPS protocol information
are used to maintain session information
Difference between GET and POST
In GET your entire form submission can be encapsulated
in one URL, like a hyperlink. query length is limited to
260 characters, not secure, faster, quick and easy.
In POST Your name/value pairs inside the body of the
HTTP request, which makes for a cleaner URL and imposes
no size limitations on the form's output. It is used to
send a chunk of data to the server to be processed, more
versatile, most secure.
What is session?
The session is an object used by a servlet to track a
user's interaction with a Web application across
multiple HTTP requests.
What is servlet mapping?
The servlet mapping defines an association between a URL
pattern and a servlet. The mapping is used to map
requests to servlets.
What is servlet context ?
The servlet context is an object that contains a
servlet's view of the Web application within which the
servlet is running. Using the context, a servlet can log
events, obtain URL references to resources, and set and
store attributes that other servlets in the context can
use. (answer supplied by Sun's tutorial).
Which interface must be implemented by all servlets?
Explain the life cycle of Servlet.
Loaded(by the container for first request or on start up
if config file suggests load-on-startup), initialized(
using init()), service(service() or doGet() or doPost()..),
destroy(destroy()) and unloaded.
When is the servlet instance created in the life cycle
of servlet? What is the importance of configuring a
An instance of servlet is created when the servlet is
loaded for the first time in the container. Init()
method is used to configure this servlet instance. This
method is called only once in the life time of a servlet,
hence it makes sense to write all those configuration
details about a servlet which are required for the whole
life of a servlet in this method.
Why don't we write a constructor in a servlet?
Container writes a no argument constructor for our
When we don't write any constructor for the servlet, how
does container create an instance of servlet?
Container creates instance of servlet by calling
Once the destroy() method is called by the container,
will the servlet be immediately destroyed? What happens
to the tasks(threads) that the servlet might be
executing at that time?
Yes, but Before calling the destroy() method, the
servlet container waits for the remaining threads that
are executing the servletís service() method to finish.
What is the difference between callling a
RequestDispatcher using ServletRequest and
We can give relative URL when we use ServletRequest and
not while using ServletContext.
Why is it that we can't give relative URL's when using
ServletContext.getRequestDispatcher() when we can use
the same while calling
Since ServletRequest has the current request path to
evaluae the relative path while ServletContext does not.
Page Numbers :