Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting full path from an HTTP request

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.

like image 469
Sergiu Avatar asked Jul 09 '26 02:07

Sergiu


1 Answers

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.

like image 106
Dave Webb Avatar answered Jul 11 '26 17:07

Dave Webb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!