I'm constructing a new URL in a Spring MVC controller, to be passed back to the client. Currently I'm trying this:
// httpRequest is the current HttpServletRequest
new URL(httpRequest.getProtocol(),
httpRequest.getServerName(),
httpRequest.getServerPort(),
httpRequest.getContextPath().concat("/foo/bar.html"));
Problem is that httpRequest.getProtocol()
gives me "HTTP/1.1" instead of just "HTTP". I can trim it but wondered if there was a more elegant way.