code: public String constructRedirectUrl(final String casServerLoginUrl, final String serviceParameterName,
        final String serviceUrl, final boolean renew, final boolean gateway) {
      try {
        return casServerLoginUrl + (casServerLoginUrl.indexOf("?") != -1 ? "&" : "?") + serviceParameterName
            + "=" + URLEncoder.encode(serviceUrl, "UTF-8") + (renew ? "&renew=true" : "")
            + (gateway ? "&gateway=true" : "") + "&" + SessionIdReader.SessionIdName + "="
            + sessionIdReader.idName();
      } catch (final UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
    }
docs: Constructs the URL to use to redirect to the CAS server.
  
  @param casServerLoginUrl the CAS Server login url.
  @param serviceParameterName the name of the parameter that defines the service.
  @param serviceUrl the actual service's url.
  @param renew whether we should send renew or not.
  @param gateway where we should send gateway or not.
  @return the fully constructed redirect url.