Are you using a normal HttpServlet here?

In that case I guess you have an incoming HttpServletRequest object. You can use the request object to get the requestURL and URI.

See...