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>SemestreSelec tedFilter< /filter-na me>
<filter-class>ies.Semestre SelectedFi lter</filt er-class>
</filter>
<filter-mapping>
<filter-name>SemestreSelec tedFilter< /filter-na me>
<url-pattern>/*.jsp</url-p attern>
</filter-mapping>
Thanks
<filter>
<filter-name>SemestreSelec
<filter-class>ies.Semestre
</filter>
<filter-mapping>
<filter-name>SemestreSelec
<url-pattern>/*.jsp</url-p
</filter-mapping>
Thanks
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have you tried just this:
<filter-mapping url-pattern="*.jsp" filter-name="ies.SemestreS electedFil ter" />
or
<filter-mapping url-pattern="/*.jsp" filter-name="ies.SemestreS electedFil ter" />
<filter-mapping url-pattern="*.jsp" filter-name="ies.SemestreS
or
<filter-mapping url-pattern="/*.jsp" filter-name="ies.SemestreS
ASKER
I have tried *.jsp.
I will try now /*.jsp and */*.jsp
I will try now /*.jsp and */*.jsp
<url-pattern>*.jsp</url-pa ttern>
has always worked for me. it could be that there is already a 'default' filter in place defined earlier in the web.xml file.
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?
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
CJ
ASKER
Once again sorry for the delay. I tried *.jsp with out the / and it worked. Thanks for the help!
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