Web Application Deployment Descriptor

April 10, 2012    blog jsp school

When working with servlets and java server pages, you need a web application deployment descriptor.

It is basically an XML file (usually called web.xml or application.xml) that tells the container about the web application.

It contains:

ServletContext initialization parameters

Servlet/JSP definitions

Servlet/JSP mappings

Welcome file list

Error pages

Problem:

JSP/Servlet page outputs a descriptor error.

Impact:

Your webpage will not run without a deployment descriptor

Solution:

Add the deployment descriptor to the project. Usually it is automatically generated, if it is not then manually input the descriptor yourself.

<?xml version=“1.0” encoding=“ISO-8859-1” ?>
<!DOCTYPE web-app PUBLIC
“-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
“http://java.sun.com/dtd/web-app_2_3.dtd”>
<web-app>
<Servlet>
<Servlet-name>Info</Servlet-name>
<Servlet-class>InfoServlet</Servlet-name>
<load-on-startup>1</load-on-startup>
</Servlet>
<Servlet-mapping>
<Servlet-name>Info</Servlet-name>
<url-pattern>/info.html</url-pattern>
</Servlet-mapping>
</web-app>