code: public synchronized String encode(String charset, boolean equalsForNullValue)
      {
          if (charset==null)
              charset=StringUtil.__ISO_8859_1;
          
          StringBuffer result = new StringBuffer(128);
          synchronized(result)
          {
              Iterator iter = entrySet().iterator();
              while(iter.hasNext())
              {
                  Map.Entry entry = (Map.Entry)iter.next();
                  
                  String key = entry.getKey().toString();
                  Object list = entry.getValue();
                  int s=LazyList.size(list);
                  
                  if (s==0)
                  {
                      result.append(encodeString(key,charset));
                      if(equalsForNullValue)
                          result.append('=');
                  }
                  else
                  {
                      for (int i=0;i<s;i++)
                      {
                          if (i>0)
                              result.append('&');
                          Object val=LazyList.get(list,i);
                          result.append(encodeString(key,charset));
  
                          if (val!=null)
                          {
                              String str=val.toString();
                              if (str.length()>0)
                              {
                                  result.append('=');
                                  result.append(encodeString(str,charset));
                              }
                              else if (equalsForNullValue)
                                  result.append('=');
                          }
                          else if (equalsForNullValue)
                              result.append('=');
                      }
                  }
                  if (iter.hasNext())
                      result.append('&');
              }
              return result.toString();
          }
      }
docs: Encode Hashtable with % encoding.
  @param equalsForNullValue if True, then an '=' is always used, even
  for parameters without a value. e.g. "blah?a=&b=&c=".