Search code examples
javawebsphereweb.xmlwelcome-file

websphere welcome-file filter not getting picked up


Below are contents of my web.xml, application is depployed in websphere 8.5

<filter>
    <filter-name>securityFilter</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>CheckFilter</filter-name>
    <url-pattern>/index.jsp</url-pattern>
</filter-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>

Issue I am facing is my CheckFilter is not getting invoked when i am hitting the url like https://servername:portNumber/contextPath/?QueryParam Same is working fine on tomcat & weblogic.

But if i enter url https://servername:portNumber/contextPath/index.jsp?QueryParam

My filter is getting invoked.To get the response for first url what should i need to change.

i.e. without giving the index.jsp filter should get called.


Solution

  • So you have two options depending on your requirements

    1) Add urlpattern on / like this (since if you call just the application context there is no index.jsp in the pattern)

    <filter-mapping>
            <filter-name>RootFilter</filter-name>
            <url-pattern>/index.jsp</url-pattern>
            <url-pattern>/</url-pattern>
    </filter-mapping>
    

    2) Since the request is forwarded to the index.jsp, you can add FORWARD to your filter mapping, like this:

    <filter-mapping>
        <filter-name>RootFilter</filter-name>
        <url-pattern>/index.jsp</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>