/** * Encodes the specified URL for use in the <code>sendRedirect</code> method * or, if encoding is not needed, returns the URL unchanged. The * implementation of this method includes the logic to determine whether the * session ID needs to be encoded in the URL. Because the rules for making * this determination can differ from those used to decide whether to encode a * normal link, this method is separated from the <code>encodeURL</code> * method. * <p> * All URLs sent to the <code>HttpServletResponse.sendRedirect</code> method * should be run through this method. Otherwise, URL rewriting cannot be used * with browsers which do not support cookies. * * @param aURL * the url to be encoded. May not be <code>null</code>. * @return the encoded URL if encoding is needed. Never <code>null</code>. * @see #encodeURL(String) */ @Nonnull default ISimpleURL encodeRedirectURL (@Nonnull final ISimpleURL aURL) { ValueEnforcer.notNull (aURL, "URL"); // Encode only the path and copy params and anchor return new SimpleURL (encodeRedirectURL (aURL.getPath ()), aURL.params (), aURL.getAnchor ()); }