0

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.

Rogger296
  • 147
  • 3
  • 15

1 Answers1

0

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>
Gas
  • 17,601
  • 4
  • 46
  • 93
  • So you have something wrong with your app, as both work correctly on my sample app. Check your web.xml (maybe attach complete) and logs (maybe you have some errors there). – Gas Sep 27 '16 at 09:13
  • Hi @Gas, I found that, in both the URLs the index.jsp is getting called. But the the one without index.jsp in url , does not call the filter and directly calls the index.jsp. And the other in which index.jsp is present, calls filter first and then index.jsp – Rogger296 Sep 28 '16 at 06:15
  • hi @Gas, I have added below in *.jsp / /index.jsp and then narrowed down to /. Has solved my problem. Thanks for your help. – Rogger296 Sep 28 '16 at 14:22