Getting full path from an HTTP request

httprequest, java, path

Solution

You need to use the `getRequestURI()` method:

The documentation describes it thus:

Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Problem

I would like to know how can I get the full path of an HTTP request. If a have a request like `http://localhost:8080/path1/path2` how can I get the full `/path1/path2`? Using `request.getContextPath()` returns only the /path1 section.

Original source