Claudia: Cookie erzeugen in Java

Beitrag lesen

Grüezi Zäme

Wer kann das folgende Script korrigieren. Das JavaBeispiel das ich aus dem Internet habe liegt bei. Leider komme ich damit nicht klar. Das Folgende ist nur ein Muster einer komplexen Meinungsumfrage bezw. TestsHomepage. Während des langwierigen Aufbaus arbeite ich auf einem simplen Webspace, das keine Unterstützung bietet, was mich auf die Javasprache einschränkt.

***JavaBeispiel set***
function setCookie(name , value , expires, path, domain, secure) {
   var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
   //alert (curCookie);
   document.cookie = curCookie;
}

***Startseite***
<HTML>
<HEAD>
<TITLE>Strauss</TITLE>
<script language="JavaScript">            ***die Funktion wird per  klick aufgerufen s. input...***
<!--
function Strauss1(Wertnotiz, value, path) {
   var curCookie = Wertnotiz + "=<table><tr><td>30</td>" +    ***TabellenAnfang eintragen***
      ((path) ? "; path=" + path: "/www/http://home.datacomm.ch/r_frei/public_html/empty.htm/");
    //alert (curCookie);
   document.cookie = curCookie;
   document.open("Blumen.htm");      **Nach Ausführung der CookieFunktion soll die Page Blumen.htm geöffnet werden wie Hyperlink***
   }
//-->
</script>
<noscript></noscript>
<script language="JavaScript">
<!--                             ***Warum wird Value speziell erwähnt, wenn sich der Name mit dem Wert verbindet?***
function Strauss2(Wertnotiz, value, path) {
   var curCookie = Wertnotiz + "=<table><tr><td>-13</td>" +
      ((path) ? "; path=" + path: "/www/http://home.datacomm.ch/r_frei/public_html/empty.htm/");
    //alert (curCookie);
   document.cookie = curCookie;
   document.open("/www/http://home.datacomm.ch/r_frei/public_html/Formular/Blumen.htm/");          ***gleich Oben mit URL-Adresse***

}
//-->
</script>
<noscript></noscript>
</HEAD>
<BODY>

<P><input alt=Strauss
src="file:///E:/public_html/Formulare/Bilder/P5060397.JPG" Type="image" onclick="Strauss1()"
style="HEIGHT: 236px; WIDTH: 171px" Alt="Strauss" id=Strauss1 width="600" height="689"></P>

<input SRC="file:///E:/public_html/Formulare/Bilder/P1010005.JPG" Type="image" ALT="Hanf" onclick="Strauss2()" style="HEIGHT: 193px; WIDTH: 214px" id=Strauss2 width="800" height="518">

</BODY>
</HTML>

***JavaBeispiel get***
function getCookie(name) {
   var dc = document.cookie;
   //alert (dc);
   var prefix = name + "=";
   var begin = dc.indexOf("; " + prefix);
   if (begin == -1) {
      begin = dc.indexOf(prefix);
      if (begin != 0) return null;
   } else
      begin += 2;
   var end = document.cookie.indexOf(";", begin);
   if (end == -1)
      end = dc.length;
   return unescape(dc.substring(begin + prefix.length, end));
}

***Letzte Seite***
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<TITLE>Blumen</TITLE>
<script language="JavaScript">          ***Weitere Wertauswahl und eintrag in Cookie***
<!--
function Blume1(Wertnotiz, value, path) {
   var curCookie = Wertnotiz + "=<td>12</td></tr></table>" +    ***Wert mit TabellenEnde***
      ((path) ? "; path=" + path: "/www/http://home.datacomm.ch/r_frei/public_html/empty.htm/");
    //alert (curCookie);
   document.cookie = curCookie;
}
//-->
</script>
<noscript></noscript>
<script language="JavaScript">
<!--
function Blume2(Wertnotiz, value, path) {
   var curCookie = Wertnotiz + "=<td>1</td></tr></table>" +
      ((path) ? "; path=" + path: "/www/http://home.datacomm.ch/r_frei/public_html/empty.htm/");
    //alert (curCookie);
   document.cookie = curCookie;
}
//-->
</script>
<noscript></noscript>

<script language="JavaScript">    ***Cookie Abfrage und eintragen in Empty.htm***
<!--
function Weiter(Wertnotiz) {
   var dc = document.cookie;
   //alert (dc);
   var prefix = Wertnotiz + "=";   ***Verstehe ich nicht!!!***
   var begin = dc.indexOf;
         begin = dc.indexOf(prefix);
        var end = document.cookie.indexOf;
         end = dc.length;
         document.open("Resultat.htm");   ***öffnen HTML***
}
//-->
</script>
<noscript></noscript>

</HEAD>

<BODY>

<P><input alt=Blume
 src="file:///E:/public_html/Formulare/Bilder/P1010008.JPG" type="image"
 onclick="Blume1()" style="HEIGHT: 215px; WIDTH: 324px" id=Blume1 width="640" height="480"></P>

<P> </P>

<P><a href="../empty.htm"><input type="image" alt=Weiter  onclick="Weiter()"
src="file://E:\public_html\Formulare\Bilder\Weiter.jpg"
style="HEIGHT: 93px; WIDTH: 95px" id=Weiter></a></P>

<P> </P>

<P><input alt=Seerose src="file://E:\public_html\Formulare\Bilder\P1010011.JPG" type="image" onclick="Blume2()"
 style   ="HEIGHT: 218px; WIDTH: 330px" id=Blume2></P>

</BODY>
</HTML>

Bis auf Weiteres grüsst Claudia