3

I have this configuration:

<servlet-mapping>
    <servlet-name>RestletServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

I need to exclude "/xrebel" since Restlet is catching this path--and can't access XRebel. However I need to keep the url-pattern to be /*

What can be done to be able to access such /xrebel path

quarks
  • 33,478
  • 73
  • 290
  • 513

2 Answers2

2

I had the same issue while developing Web Services last year. But after doing a lot of research I found that there was no easy to do solution for the problem.

Instead the best approach I found was to use prefix servlet URL.

So for all the mappings which you want to be handled by RestletServlet add a prefix to url something like /rest/*

Hope this helps.

Shubham Kadlag
  • 2,248
  • 1
  • 13
  • 32
0

One possible solution is to create a filter with the same url pattern to intercept the request.

In your filter you can check if the pattern is equal to /xrebel and then handle the request however you want to.

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    String requri = ((HttpServletRequest) request).getRequestURI().substring(((HttpServletRequest) request).getContextPath().length() + 1);
    System.out.println(requri);
    if(requri.equals("/xrebel")){

    //do something else

    }else{
       chain.doFilter(request, response);   //continue normally
      }
}
Jonathan Laliberte
  • 2,672
  • 4
  • 19
  • 44