Link to home
Start Free TrialLog in
Avatar of menreeq
menreeq

asked on

Filter Setup

I am having trouble setup a filter to function on only my jsp files. Below is what i have in my web.xml file. But it does not function.  How do i specify this correctly?

<filter>
<filter-name>SemestreSelectedFilter</filter-name>
<filter-class>ies.SemestreSelectedFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SemestreSelectedFilter</filter-name>
<url-pattern>/*.jsp</url-pattern>
</filter-mapping>

Thanks
Avatar of cheekycj
cheekycj
Flag of United States of America image

what is not working?

How do you know your filter is not being invoked?

Make sure you are using a servlet engine (Tomcat 4.0 and greater or a servlet engine that supports Servlet 2.3 spec) that supports Filters.

CJ
Avatar of menreeq
menreeq

ASKER

When i use "/*.jsp" it does not invoke the filter for any files.  I know it works because when i change it to "/*" it functions on all the files, including the images in the sub-directory.  

Perhaps it´s due to me calling url-pattern and not specifying a valid pattern?  Or is "/*.jsp" a valid url-pattern?
ASKER CERTIFIED SOLUTION
Avatar of pellep
pellep
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
have you tried just this:

<filter-mapping url-pattern="*.jsp" filter-name="ies.SemestreSelectedFilter" />

or

<filter-mapping url-pattern="/*.jsp" filter-name="ies.SemestreSelectedFilter" />
Avatar of menreeq

ASKER

I have tried *.jsp.

I will try now /*.jsp and */*.jsp

<url-pattern>*.jsp</url-pattern>
has always worked for me. it could be that there is already a 'default' filter in place defined earlier in the web.xml file.
any updates?
Avatar of menreeq

ASKER

Ya, my computer got a virus, trying to resrore everthing.  Will try your suggestion just as soon as i have everything back online.
ok.  sorry to hear about the virus.. take your time and let us know.

CJ
Avatar of menreeq

ASKER

Once again sorry for the delay. I tried *.jsp with out the / and it worked.  Thanks for the help!