title: How to configure web.xml for multiple url-pattern for sitemesh filter. i believe i'm using servlet api 2.5
body: <p>i've been struggling to enable multiple ulr-pattern for a web site using Spring mvc 3.0.5 sitemesh 2.4.2.my container is tomcat 6.0.26 my pom looks like this:</p>
  
  <pre><code> &lt;dependency&gt;
     &lt;groupId&gt;org.freemarker&lt;/groupId&gt;
       &lt;artifactId&gt;freemarker&lt;/artifactId&gt;
              &lt;version&gt;2.3.14&lt;/version&gt;
   &lt;/dependency&gt;
   &lt;dependency&gt;
     &lt;groupId&gt;opensymphony&lt;/groupId&gt;
        &lt;artifactId&gt;sitemesh&lt;/artifactId&gt;
            &lt;version&gt;2.4.2&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
   &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
        &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
        &lt;version&gt;2.1&lt;/version&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
         &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
            &lt;version&gt;2.5&lt;/version&gt;
            &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  </code></pre>
  
  <p>i'm using another view technology which is ZK for the admin site of the application.  </p>
  
  <p>sitemesh is supposed to take care of <code>/site/*</code> and leave the <code>/admin/*</code> every was fine until this week i wanted to add mobile wap view for the app.am not providing any site redirecting of the kind <code>m.mysite.com</code> or <code>mysite.mobi</code> , i'm just using <code>spring mvc</code> request mapping to have  <code>/wap/*</code>  which point to the same controllers and action as <code>/site/*</code>. so my problem would be telling sitemesh to handle <code>/wap/*</code> too.</p>
  
  <p>my web.xml looks like this:</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;sitemesh-freemarker&lt;/servlet-name&gt;
      &lt;servlet-class&gt;freemarker.ext.servlet.FreemarkerServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;TemplatePath&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/ui/views&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;NoCache&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;ContentType&lt;/param-name&gt;
          &lt;param-value&gt;text/html; charset=UTF-8&lt;/param-value&gt;
          &lt;!-- Forces UTF-8 output encoding! --&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;!--  FreeMaker section   --&gt;
  
  
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;sitemesh-freemarker&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.ftd&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;sitemesh-freemarker&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.ftl&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;sitemesh-freemarker&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;sitemesh-freemarker&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.dec&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;!--  End FreeMaker section  --&gt;
  
  
  
  &lt;!-- Sitemesh --&gt;
  
  &lt;filter&gt;
      &lt;filter-name&gt;sitemesh&lt;/filter-name&gt;
      &lt;filter-class&gt;com.opensymphony.sitemesh.webapp.SiteMeshFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  &lt;!--  Sitemesh   --&gt;
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;sitemesh&lt;/filter-name&gt;
      &lt;url-pattern&gt;/site/*&lt;/url-pattern&gt; &lt;!--this is decorated--&gt;
      &lt;url-pattern&gt;/wap/*&lt;/url-pattern&gt; &lt;!--this is not --&gt;
      &lt;!--&lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt;--&gt;
      &lt;!--&lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;--&gt;
  &lt;/filter-mapping&gt;
  
  &lt;!--this bellow doesn't work as page not decorated--&gt;
  &lt;!--&lt;filter-mapping&gt;--&gt;
      &lt;!--&lt;filter-name&gt;sitemesh&lt;/filter-name&gt;--&gt;
      &lt;!--&lt;url-pattern&gt;/wap/*&lt;/url-pattern&gt;--&gt;
  &lt;!--&lt;/filter-mapping&gt;--&gt;
  &lt;!-- End of Sitemesh   --&gt;
  </code></pre>
  
  <p>According to <a href="http://www.coderanch.com/t/485819/Servlets/java/Multiple-url-pattern-filter-mapping" rel="nofollow">coderanch</a> both are supposed to work though it's not about sitemesh. I think it doesn't matter since <code>siteMeshFilter</code> implements <code>javax.servlet.Filter</code> </p>
  
  <p>this is  my HomeController action </p>
  
  <pre><code>@RequestMapping("/")
  public String index(HttpServletRequest request) {
      final org.springframework.mobile.device.Device device = DeviceUtils.getCurrentDevice(request);
  
      if(device.isMobile()){
          return "redirect:/site/waphome";
      } else {
          return "redirect:/site/home";
      }
  
  }
  
  
  @RequestMapping(value = {"/site","/site/home","/site/home","/wap","/wap/","/wap/home"})
  public String home(Model model, HttpServletRequest request, HttpSession session) {
      final org.springframework.mobile.device.Device device = DeviceUtils.getCurrentDevice(request);
  
     // ....
  
      if(device.isMobile()){
          return "waphome";
      } else {
          return "home";
      }
  
  }
  </code></pre>