users@jersey.java.net

[Jersey] How to get matched path in jersey 1.0

From: Magesh STM <magesh_stm_at_yahoo.com>
Date: Wed, 13 Aug 2014 22:38:37 -0700

I have this following question. Please help.

Please refer following code. /hello/from/JohnDoe will hit the method sayPlainTextHello.

When "/hello/from/JohnDoe" is accessed, I want to store the matched path which is /hello/from/{name} in a log. Please note that I can't modify below code but can add filter, etc. to the app. How to get the matched path "/hello/from/{name}" ?

    @Path("hello")
    public class SayHello {

        @GET
        @Produces(MediaType.TEXT_PLAIN)
        @Path("/from/{name}")
        public String sayPlainTextHello(@PathParam("name") String fromName) {
            return "Hello Jersey - " + fromName;
        }
    }