javajettyjetty-9jetty-8

How to I get rid of extra / in http://localhost:8080/test/ in Jetty?


I want any user trying to access http://localhost:8080/test/ to be redirected to http://localhost:8080/test. I want to remove the extra '/' after test.

I tried writing this in rewrite rules but it doesn't work for me.


Solution

  • If your contextPath is /test then the extra slash is required to satisfy the context path rules of both the servlet spec and the URI / http resource declarations of the various RFCs.

    If you set your web application, handler, context, etc with the "context path" of /test then you'll want to switch to using / (the root context) and having a servlet url-pattern of /test (exactly named /test).