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
menreeqAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
pellepConnect With a Mentor Commented:
try
*/*.jsp
or
*.jsp
0
 
cheekycjCommented:
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
0
 
menreeqAuthor Commented:
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?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
cheekycjCommented:
have you tried just this:

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

or

<filter-mapping url-pattern="/*.jsp" filter-name="ies.SemestreSelectedFilter" />
0
 
menreeqAuthor Commented:
I have tried *.jsp.

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

0
 
pellepCommented:
<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.
0
 
cheekycjCommented:
any updates?
0
 
menreeqAuthor Commented:
Ya, my computer got a virus, trying to resrore everthing.  Will try your suggestion just as soon as i have everything back online.
0
 
cheekycjCommented:
ok.  sorry to hear about the virus.. take your time and let us know.

CJ
0
 
menreeqAuthor Commented:
Once again sorry for the delay. I tried *.jsp with out the / and it worked.  Thanks for the help!
0
All Courses

From novice to tech pro — start learning today.