最佳答案
I am writing a code which task is to retrieve a requested URL or full path. I've written this code:
HttpServletRequest request;//obtained from other functions
String uri = request.getRequestURI();
if (request.getQueryString() != null)
uri += "?" + request.getQueryString();
So, when I browse http://google.com?q=abc
it is OK (correct).
But there is problem when I browse https://google.com
. The value of uri
is http://google.com:443google.com:443
, So the program doesn't only when HTTPS
is used.
And the output is same for request.getRequestURL().toString()
.
What is the solution?