Wednesday, December 3, 2014

Use .replace to remove a piece of a string in Java!

String uri = request.getScheme() + "://" + request.getServerName();
if(request.getServerPort() != 80) {
   uri = uri + ":" + request.getServerPort();
}
uri = uri + request.getRequestURI();
uri = uri.replace(request.getServletPath(),"");

No comments:

Post a Comment