I have rest service implemented.
I am trying to get the path parameters of the the request in filter.
My request is
/api/test/{id1}/{status}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException
{
//Way to get the path parameters id1 and status
}
There's no other way to do it in a ServletFilter other than trying to parse the URI yourself, but you can access the path parameters if you decide to use a JAX-RS request filter:
@Provider
public class PathParamterFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext request) throws IOException {
MultivaluedMap<String, String> pathParameters = request.getUriInfo().getPathParameters();
pathParameters.get("status");
....
}
}