Home

webxml

Web.xml is the deployment descriptor for a Java web application, used to configure how a servlet container should deploy and run the app. It is located in the WEB-INF directory as WEB-INF/web.xml and is read when the application is deployed or started. The descriptor defines the components and settings that govern the application’s behavior, including servlets, filters, listeners, and various environment and security configurations.

The file specifies how the application’s components are wired together and how they respond to requests. Common

Structure and elements can vary by the version of the servlet specification. The root element is typically

configurations
include
servlet
definitions
and
mappings,
filter
declarations
and
mappings,
and
listener
registrations.
It
can
also
declare
context
parameters,
init
parameters
for
individual
components,
environment
entries,
and
resource
references.
Additional
sections
may
define
welcome
files,
error
pages,
and
security
constraints
such
as
login
configurations
and
access
restrictions.
<web-app>,
with
a
version
attribute
(for
example,
2.5,
3.0,
or
3.1)
and,
in
newer
environments,
an
XML
namespace.
Early
deployments
used
a
DTD,
while
newer
ones
use
XML
schemas.
Since
Servlet
3.0,
some
configurations
can
be
achieved
with
annotations
in
the
code,
which
can
reduce
or
even
replace
the
need
for
web.xml.
Nevertheless,
web.xml
remains
a
portable,
centralized
way
to
manage
deployment
details,
and
is
still
widely
used
in
Jakarta
EE
and
Java
EE
applications
for
compatibility
and
explicit
control
over
container
behavior.