views:

92

answers:

2

I have what I think is a bizarre problem.

With the same mapping to a servlet, one url works, and the other doesn't:

    <servlet-mapping>
    <servlet-name>UL_Admin</servlet-name>
       <url-pattern>/universal_listings_administration/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
      <servlet-name>Create_New_Site</servlet-name>
      <url-pattern>/universal_listings_administration/sites/new_site/*</url-pattern>
    </servlet-mapping>
   <servlet-mapping>
    <servlet-name>Create_New_Site</servlet-name>
    <url_pattern>/universal_listings_administration/sites/delete_site/*</url_pattern>
   </servlet-mapping>

Create_New_Site works for /universal_listings_administration/sites/new_site/* but not for /universal_listings_administration/sites/delete_site/*

When going to /universal_listings_administration/sites/delete_site/* the site simply goes to the UL_Admin!!!

I've changed the ordering of the urls, but get the same results. I've tried this on different browsers, thinking it could be a caching problem, but get the same results every time.

Does anyone have any idea about what's going on here???

The only other thing that I think it could be is my filters or something? I've had a look but everything seemed to be working fine with the filters. Anyway here's my security and filter settings in web.xml

    <security-constraint>
        <web-resource-collection>
            <url-pattern>/universal_listings_administration/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <url-pattern>/jsps/admin/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <url-pattern>/stylesheets/admin/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>

    <!-- Filters -->
     <filter>
  <!-- This filter defines all of the URIs on the site, to ensure easy to update URIs -->
  <!-- All URIs defined here will be added to the request's Attributes -->
  <!-- The URIs follow naming convention uri-name or uri-admin-name -->
  <!-- For simplicity sake, do this only for client URIs (internal can be covered by eclipse!) -->
  <filter-name>UriSettingFilter</filter-name>
  <filter-class>nz.co.unilistings.control.UriAttributeSettingFilter</filter-class>
  <init-param>
   <param-name>uri-admin-portal</param-name>
   <param-value>/universal_listings_administration/</param-value>
  </init-param>
  <init-param>
   <param-name>uri-admin-new-site</param-name>
   <param-value>/universal_listings_administration/sites/new_site/</param-value>
  </init-param>
  <init-param>
   <param-name>uri-admin-delete-site</param-name>
   <param-value>/universal_listings_administration/sites/delete_site/</param-value>
  </init-param>
 </filter>
 <filter>
     <filter-name>SubdomainFilter</filter-name>
     <filter-class>nz.co.unilistings.control.SubdomainFilter</filter-class>
     <init-param>
   <description>Any subdomain with this value will go to the parent site</description>
   <param-name>parent_site_subdomain</param-name>
   <param-value>www</param-value>
  </init-param>
     <init-param>
   <description>The URL of the parent site (where people can register)</description>
   <param-name>parent_url</param-name>
   <param-value>http://www.example.com:8888&lt;/param-value&gt;
  </init-param>
 </filter>

 <filter-mapping>
    <filter-name>SubdomainFilter</filter-name>
    <servlet-name>*</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
 </filter-mapping>  
 <filter-mapping>
  <filter-name>UriSettingFilter</filter-name>
  <servlet-name>*</servlet-name>
  <dispatcher>REQUEST</dispatcher>  
  <dispatcher>FORWARD</dispatcher>
  <dispatcher>INCLUDE</dispatcher>
  <dispatcher>ERROR</dispatcher>
 </filter-mapping>

An update:

I did some debugging, I am certain that I'm going to the correct URL, (copy, paste from web.xml), and Here's what I get in the request when it hits the first filter (comparing create_site and delete_site:

create_site: http://www.example.com:8888/universal_listings_administration/sites/new_site/ _pathInfo: "/" _requestURI: "/universal_listings_administration/sites/new_site/" _servletPath: "/universal_listings_administration/sites/new_site" _uri: "/universal_listings_administration/sites/new_site/"

delete_site: http://www.example.com:8888/universal_listings_administration/sites/delete_site/ _pathInfo: "/sites/delete_site/" _requestURI: "/universal_listings_administration/sites/delete_site/" _servletPath: "/universal_listings_administration" _uri: "/universal_listings_administration/sites/delete_site/"

I guess now I have to figure out why the _pathInfo and _servletPath are quite different...

A: 

The mappings look fine. The symptoms at least indicate that either the actual URL was wrong or some filter or servlet has changed the request/response destination before or after the servlet was reached.

This issue is hard to nail down without debugging/logging all the servlets and filters to track the execution path of the HttpServletRequest instance throughout the code. And since we don't have access to your code/environment to reproduce the problem, this task is entirely up to you.

BalusC
A: 

I think there must have been something wrong in my web.xml with the url-mapping. must have been very subtle, only fixed by copying and pasting another servlet-mapping and changing the url.

Possible causes: using a german keyboard, and switching between english and german???

Louis Sayers