Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Servlet Mappings

I have a servlet defined as in web.xml:

<servlet-mapping>
  <servlet-name>SessionRebindServlet</servlet-name>
  <url-pattern>*.ppp</url-pattern>
</servlet-mapping>

Now when there is a request with extension .ppp it uses the above servlet.

But I want to have one exception here that if the file with name "popup.ppp" then don't call this servlet at all.

Is it possible?

UPDATE

I added a filter

<filter-mapping>
    <filter-name>AppFilter</filter-name>
    <url-pattern>*.ppp</url-pattern>
</filter-mapping>

and in filter code :

String url = ((HttpServletRequest) request).getRequestURI();
        if (url.contains("popup.ppp")) {

        } else {
            chain.doFilter(request, response);
        }
like image 574
Makky Avatar asked Feb 18 '26 08:02

Makky


1 Answers

I use this for such cases:

String lPath = ((HttpServletRequest) request).getRequestURI();
if (lPath.startsWith("/supported")) {
   chain.doFilter(request, response); 
} else {
  // not supported
}
like image 96
s_bei Avatar answered Feb 19 '26 20:02

s_bei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!