java - Filters - Ignore the other requests excluding the welcome file -
i wrote filter decide user landing page before reach welcome-file. welcome-file written in such way takes input filter , navigate user specific page.
my welcome-file tag is...
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list>
and filter configuration
<filter> <filter-name>landingpagefilter</filter-name> <filter-class>com.mypack.test.filters.landingpagefilter</filter-class> </filter> <filter-mapping> <filter-name>landingpagefilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
the above format working whilst every request passing through filter, want avoid. when hit http://localhost:8000/landing
should reach filter first time , later if access http://localhost:8000/landing/edit
should execute relevant servlet bypassing filter.
i tried <url-pattern>/*/index.jsp</url-pattern>
no use. why use because context may vary app same.
use
<url-pattern>/index.jsp</url-pattern>
instead of
<url-pattern>/*/index.jsp</url-pattern>
so filter mapping part become this
<filter-mapping> <filter-name>landingpagefilter</filter-name> <url-pattern>/index.jsp</url-pattern> </filter-mapping>
irrespective of context works because /
represents path after context path.
for example if have 2 context paths a , b 2 deployments of same application in server , accessing them using urls
http://localhost:8000/a/
and
http://localhost:8000/b/
then /
in url-pattern
represents /
after context roots a
, b
. filter executed index.jsp.
Comments
Post a Comment