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 ?
You can omit the first character since it's always a slash:
request.getPathInfo().substring(1).split("/")