Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requested Path JAX-RS

how can I write the following in correct Java?:

@GET
@Path("{blah}/{blahh}")
public String getAnything(@PathParam("blah") String blah, 
                          @PathParam("blahh") String blahh,
                          @Path String path) {
  return "<a href=" + path + ">Hi</a>";
}

I want to get the whole requested Path in a variable. How do I do this? I'm using Jersey, JAX-RS and Tomcat.

like image 783
Maxiking1011 Avatar asked Feb 01 '13 11:02

Maxiking1011


1 Answers

You should add the UriInfo parameter:

@GET
@Path("{blah}/{blahh}")
public String getAnything(@PathParam("blah") String blah, 
                          @PathParam("blahh") String blahh,
                          @Context UriInfo uriInfo) {
  return "<a href='" + uriInfo.getAbsolutePath() + "'>Hi</a>";
}
like image 56
Carlo Pellegrini Avatar answered Sep 28 '22 08:09

Carlo Pellegrini