code: public static String getRedirectLocation(
  		HttpServletRequest request,
  		HttpServletResponse response,
  		String servletPath,
  		String href
  	) throws MalformedURLException, UnsupportedEncodingException {
  		// Convert page-relative paths to context-relative path, resolving ./ and ../
  		href = getAbsolutePath(servletPath, href);
  
  		// Encode URL path elements (like Japanese filenames)
  		href = UrlUtils.encodeUrlPath(href, response.getCharacterEncoding());
  
  		// Perform URL rewriting
  		href = response.encodeRedirectURL(href);
  
  		// Convert to absolute URL if needed.  This will also add the context path.
  		if(href.startsWith("/")) href = getAbsoluteURL(request, href);
  
  		return href;
  	}
docs: Gets the absolute URL that should be used for a redirect.
  
  @param  href  The absolute, context-relative, or page-relative path to redirect to.
  The following actions are performed on the provided href:
  <ol>
  <li>Convert page-relative paths to context-relative path, resolving ./ and ../</li>
  <li>Encode URL path elements (like Japanese filenames)</li>
  <li>Perform URL rewriting (response.encodeRedirectURL)</li>
  <li>Convert to absolute URL if needed.  This will also add the context path.</li>
  </ol>
  
  @see  #sendRedirect(javax.servlet.http.HttpServletResponse, java.lang.String, int)