public static void htmlWriteQueryFormPageFromTemplate(OutputStream stream, InputStream templatestream) {
    { KeyValueList variables = KeyValueList.newKeyValueList();
      String formheader = "<FORM NAME='QUERY' METHOD='POST' ACTION='do-query' ENCTYPE='application/www-url-form-encoded'>";

      variables.insertAt(StringWrapper.wrapString("MODULE-MENU"), StringWrapper.wrapString(OntosaurusUtil.yieldModuleMenuString(OntosaurusUtil.sortedContexts())));
      formheader = formheader + Stella.EOL_STRING + OntosaurusUtil.yieldPresetQueriesScript(((Cons)(OntosaurusUtil.$PRESET_QUERIES$.get())));
      variables.insertAt(StringWrapper.wrapString("QUERY-MENU"), StringWrapper.wrapString(OntosaurusUtil.yieldQueryMenuString(((Cons)(OntosaurusUtil.$PRESET_QUERIES$.get())))));
      variables.insertAt(StringWrapper.wrapString("NOF-ANSWERS-MENU"), StringWrapper.wrapString(OntosaurusUtil.yieldNofAnswersMenuString(Stella.getQuotedTree("((\"All\" \"1\" \"2\" \"5\" \"10\" \"20\" \"50\" \"100\") \"/ONTOSAURUS\")", "/ONTOSAURUS"))));
      variables.insertAt(StringWrapper.wrapString("TIMEOUTS-MENU"), StringWrapper.wrapString(OntosaurusUtil.yieldTimeoutsMenuString(Stella.getQuotedTree("((\"None\" \"1.0\" \"2.0\" \"5.0\" \"10.0\" \"30.0\" \"60.0\" \"120.0\") \"/ONTOSAURUS\")", "/ONTOSAURUS"))));
      variables.insertAt(StringWrapper.wrapString("QUERY-INPUT-AREA"), StringWrapper.wrapString("<TEXTAREA NAME='QUERYSOURCE' ROWS='4' COLS='80'></TEXTAREA>"));
      variables.insertAt(StringWrapper.wrapString("SUBMIT-BUTTON"), StringWrapper.wrapString("<INPUT TYPE='SUBMIT' VALUE='Submit'>"));
      variables.insertAt(StringWrapper.wrapString("RESET-BUTTON"), StringWrapper.wrapString("<INPUT TYPE='RESET' VALUE='Clear'>"));
      variables.insertAt(StringWrapper.wrapString("FORM-TRAILER"), StringWrapper.wrapString("</FORM>"));
      formheader = formheader + Stella.EOL_STRING + "<SCRIPT LANGUAGE='JavaScript'>\nvar cookieValue = document.cookie.substring(document.cookie.indexOf('qmodule=')+8,document.cookie.length);\nif (cookieValue.indexOf(';') != -1) {\ncookieValue = cookieValue.substring(0,cookieValue.indexOf(';'));\n}\nfor (var i = 0; i < document.QUERY.MODULE.length; i++) {\n   if (document.QUERY.MODULE[i].value==cookieValue) {\n     document.QUERY.MODULE.selectedIndex = i; }\n}</SCRIPT>";
      variables.insertAt(StringWrapper.wrapString("FORM-HEADER"), StringWrapper.wrapString(formheader));
      InputStream.substituteTemplateVariablesToStream(templatestream, stream, variables);
    }
  }