web applications - java: question on filter and servlet mapping -
i have web application following structure:
tomcat_home | webapps |_myapp |-html/ |-various directories |-web-inf/ |-index.html the application has various servlets registered on various paths.
application can accessed via http://ip:port/myapp/
of courses causes index.html (in welcome list).
question is, how register filter access of root directory not subdirectories i.e. url-mapping not /* if place url-pattern / seems not work.
filter intercept request http://ip:port/myapp/ , not http://ip:port/myapp/path or http://ip:port/myapp/servlet/path.
additionally filter intercept request http://ip:port/myapp/index.html equivalent 1 aim.
thanks
you can test / , thing, otherwise let pass through. /* url pattern.
@override public void dofilter(servletrequest req,servletresponse res,filterchain chain) throws ioexception,servletexception{ httpservletrequest request=(httpservletrequest)req; string path=request.getservletpath(); if(path.equals("/") || path.equals("/index.html"){ // thing } chain.dofilter(req,res); }
Comments
Post a Comment