title: Tomcat: Servlet Mapping vs. WebServlet Annotation
body: <p>There are two ways for servlet mapping.
  The first is in web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
     &lt;servlet-name&gt;foo&lt;/servlet-name&gt;
     &lt;servlet-class&gt;com.whatever.foo&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
     &lt;servlet-name&gt;foo&lt;/servlet-name&gt;
     &lt;url-pattern&gt;/foo&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>The second method uses the WebServlet annotation:</p>
  
  <pre><code>@WebServlet("/foo")
  public class foo extends HttpServlet {
  ...
  }
  </code></pre>
  
  <p><strong>Which one is better</strong>? Where are the <strong>advantages</strong> of the first and the second way?</p>