title: Java Servlet URL Mapping
body: <p>i fairly new to java servlet. </p>
  
  <p>Please forgive me if this question seems stupid.</p>
  
  <p>I have add servlet mapping such as servlet class and url pattern using netbeans in web.xml servlet tab but when the application was running it does not direct go into the target url which is <a href="http://localhost:8080/HelloDuke2/greeting" rel="nofollow">http://localhost:8080/HelloDuke2/greeting</a> but
  <a href="http://localhost:8080/HelloDuke2/" rel="nofollow">http://localhost:8080/HelloDuke2/</a></p>
  
  <p>What am i missing in the configuration ? </p>
  
  <p>How to set the start up url to <a href="http://localhost:8080/HelloDuke2/greeting" rel="nofollow">http://localhost:8080/HelloDuke2/greeting</a> ? </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
  &lt;context-param&gt;
  &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
  &lt;param-value&gt;Development&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;GreetingDukeServlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;HelloDuke.GreetingDukeServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;ResponseDukeServlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;HelloDuke.ResponseDukeServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;ResponseDukeServlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/ResponseDukeServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;GreetingDukeServlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/GreetingDukeServlet&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;session-config&gt;
  &lt;session-timeout&gt;
  30
  &lt;/session-timeout&gt;
  &lt;/session-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Please help. </p>
  
  <p>Thanks.</p>
  
  <p>EDIT:</p>
  
  <p>I have tried the solution provided by Alexey Sviridov but it doesn't works where the browser report http status 404 resource is not available. </p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Development&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;GreetingDukeServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;HelloDuke.GreetingDukeServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;ResponseDukeServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;HelloDuke.ResponseDukeServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;Message&lt;/param-name&gt;
              &lt;param-value&gt;Hello, PeterWkc&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;GreetingDukeServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/GreetingDukeServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;ResponseDukeServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/ResponseDukeServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>index.xhtml</p>
  
  <pre><code>&gt; &lt;?xml version='1.0' encoding='UTF-8'
  &gt; ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD
  &gt; XHTML 1.0 Transitional//EN"
  &gt; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &gt; &lt;html
  &gt; xmlns="http://www.w3.org/1999/xhtml"
  &gt;       xmlns:h="http://java.sun.com/jsf/html"&gt;
  &gt;     &lt;h:head&gt;
  &gt;         &lt;title&gt;Hello Duke&lt;/title&gt;
  &gt;         &lt;meta http-equiv="REFRESH" content="0; url=GreetingDukeServlet/"&gt;
  &gt;             
  &gt;         &lt;/meta&gt;
  &gt;         
  &gt; 
  &gt;     &lt;/h:head&gt;
  &gt;     &lt;h:body&gt;
  &gt;         Hello from Facelets
  &gt; 
  &gt; 
  &gt; 
  &gt;     &lt;/h:body&gt; &lt;/html&gt;
  </code></pre>
  
  <p>Please help. </p>
  
  <p>Thanks. </p>