title: should I make two different servlet entry for rest and normal html in web.xml
body: <p>I am writing spring mvc application.</p>
  
  <p>In my application I have web pages as well as rest web services to handle ajax call.</p>
  
  <p>I have done below entry in web.xml</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring_myapp-servlet.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Should I map my rest url with same servlet like</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Or should I make new servlet entry for rest.</p>
  
  <p>I have done required entries in pom.xml for "org.codehaus.jackson" and also I have made required entries in my spring_myapp-servlet.xml.</p>
  
  <p>For html page I am using below code in my controller</p>
  
  <pre><code>@RequestMapping(value = "/htmlUrl")
  public ModelAndView ModifyValiodation(HttpServletRequest request) {
       // my code
  }
  </code></pre>
  
  <p>For rest service I am using</p>
  
  <pre><code>@RequestMapping(value = "/restUrl")
  public @ResponseBody Map&lt;String, String&gt; restUrl(HttpServletRequest request) {
       // my code
  }
  </code></pre>
  
  <p>If I am using only one servlet for two url mapping, then total 4 url will be made.</p>
  
  <ol>
  <li>myapp/htmlUrl.html</li>
  <li>myapp/restUrl.html</li>
  <li>myapp/rest/htmlUrl</li>
  <li>myapp/rest/restUrl</li>
  </ol>
  
  <p>If I am using two different servlet with individual dispacherServlet then will i have to make entry of every component and service of spring in both the servlet.xml?</p>
  
  <p>Please point out the solution for exposing rest web service.</p>
  
  <p>Thanks!</p>