0

So we are running a web application that has been tested on Tomcat, Glassfish, WebLogic and WebSphere. All run correctly except WebSphere. The issue is that filters are not processed for files under a certain directory.

For example I have a filter that checks the user's lanuage from browser cookies and another that get the user's username, in the web.xml there are configured like so:

<!-- ****************************** -->
<!-- * Security context filtering * -->
<!-- ****************************** -->

<filter>
    <filter-name>SetSecurityContextFilter</filter-name>
    <filter-class>
        com.test.security.SecurityContextServletFilter
    </filter-class>
</filter>

<!-- ****************************** -->
<!-- ** Locale context filtering ** -->
<!-- ****************************** -->

<filter>
    <filter-name>SetLocaleFilter</filter-name>
    <filter-class>
        com.test.locale.LocaleServletFilter
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>SetSecurityContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>SetLocaleFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping> 

Both filters set a static threadlocal variable which can be accessed from a static getter, but when the same file 'test.jsp' invokes the getters, under 'contextroot/js' they return the default values (as if unset) while under 'contextroot/pages' they are correct.

Any ideas?

Thanks in advance.

3
  • Also perhaps worth mentioning; we tested WebSphere on UNIX, the others were all tested on Windows. Commented Dec 10, 2009 at 9:35
  • With Unix, I assume you meant AIX? I see nothing wrong with the filter definition, so maybe it is something in the code, do your filters write debug information so you can see that they are invoked or not? Commented Dec 10, 2009 at 10:20
  • Yep, AIX. It seems unlikely to be the code though, does it not?...sinc all other web containers handle this fine. Unfortunately I don't have any logging currently so can't be 100% in saying that they are not invoked - will take a while but I'll try and get the filters to do some logging. Cheers Commented Dec 10, 2009 at 10:52

2 Answers 2

2

I have discovered what the problem was!

In my web.xml further down I have this:

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Test Application</web-resource-name>
            <url-pattern>/pages/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
             ...
        </auth-constraint>
    </security-constraint>

If I change the URL pattern to '/*' so that every page under the context root requires a login, all filters are correctly run, all the time. This does however mean that my login page doesn't have access to any css files but that's another problem!

Cheers.

Sign up to request clarification or add additional context in comments.

Comments

0

Defining your login page as the form-login-page might help it get css resources as follows <form-login-config> <form-login-page>/Login.jsp</form-login-page>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.