2

I have the following servlet:

@WebServlet("/publication/topic/*")
public class ViewTopicPublicationsServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) {
        String[] pathInfo = request.getPathInfo().split("/");
        System.out.println(Arrays.toString(pathInfo));
        ...
    }
}

And for example if I have such url: http://localhost:8080/bulletinboard/publication/topic/SALE

I want to omit empty string. So pathInfo resulted in [SALE] instead of [,SALE]

How this may be achieved ?

RĂ¼diger Herrmann
  • 20,512
  • 11
  • 62
  • 79
marknorkin
  • 3,904
  • 10
  • 46
  • 82

1 Answers1

1

You can omit the first character since it's always a slash:

request.getPathInfo().substring(1).split("/")
FuRioN
  • 623
  • 5
  • 12