If URI is super set of URL then how come it got this following output ...
The definitions of URI and URL cannot be used to infer the behaviour of getRequestURI()
and getRequestURL()
. To understand what the methods return, you need to read the javadocs and the Servlet specification.
The meaning of those methods are what they are because the HttpRequest
API has evolved over time, and that evolution has had to maintain backwards compatibility.
getRequestURI()
does return a URI, and getRequestURL()
does return a URL, but the URI and URL are for different things.