For this URL:
http://localhost:8888/myapp/myservlet/item
In my servlet inside doGet method:
System.out.println("req.getServletPath(): " + req.getServletPath());
System.out.println("req.getRequestURL(): " + req.getRequestURL());
System.out.println("req.getRequestURI(): " + req.getRequestURI());
System.out.println("req.getContextPath(): " + req.getContextPath());
System.out.println("req.getPathInfo(): " + req.getPathInfo());
Console output:
req.getServletPath():
req.getRequestURL(): http://localhost:8888/myapp/myservlet/item
req.getRequestURI(): /myapp/myservlet/item
req.getContextPath():
req.getPathInfo(): /myapp/myservlet/item
Why is the getContextPath and getServletPath empty?
If it matters this is a (google) web-project in eclipse which gets deployed on jetty.
I am trying to get part of URL that is after the servlet name i.e /item in this case.
/myapp? Why?