• Post Reply Bookmark Topic Watch Topic
  • New Topic

url-pattern for filters

 
muthu bharathi
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to give the url pattern in filters in web.xml

My web.xml is like the following

<filter>
<filter-name>TokenGuard</filter-name>
<filter-class>com.app.core.token.TokenGuard</filter-class>
</filter>
<filter-mapping>
<filter-name>TokenGuard</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

but it doesn't work... may i know the above url-pattern is correct or wrong...
or
how can we declare a filter to operate on more than one url pattern

if i give the url pattern like like <url-pattern>*.jsp</url-pattern> it works fine....

please help meeeee..
 
Deepali Anand
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
muthu bharathi wrote:Hi,

How to give the url pattern in filters in web.xml

My web.xml is like the following

<filter>
<filter-name>TokenGuard</filter-name>
<filter-class>com.app.core.token.TokenGuard</filter-class>
</filter>
<filter-mapping>
<filter-name>TokenGuard</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

but it doesn't work... may i know the above url-pattern is correct or wrong...
or
how can we declare a filter to operate on more than one url pattern

if i give the url pattern like like <url-pattern>*.jsp</url-pattern> it works fine....

please help meeeee..


According to me, your filter mapping is correct. Can you explain in detail what is happening?

If you need a filter to operate on more than one url pattern, you must declare it for each of the patterns.
It is executed first for exact match(for eg.../folder1/filter1.do), then for Directory match(/folder1/) and last for extension (*.do)


 
swapnl patil
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell me the exact problem or error is coming
 
muthu bharathi
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for your response.

If i enable the <filter>..... </filter>blank page is displayed when the null pointer exception is fired.

in my application i've use the <error code> tag, if any exception arise it'll display the corresponding exception page.

if i disable the <filter>....</filter> it works fine.... i dont know what is the reason?
--
regds,
M. Bharathi
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!