The July JAM |
|
This applet uses the HTTProtocol for invoking the GeoCities mail
script, that sends e-mail messages to GeoCities members.
Hereinafter is the java-source.
If you are a GeoCitizen, you could use this applet for your own automatic e-mail messages, by adding the following HTML-tags to your page(s).
<APPLET CODE="MailApplet.class" CODEBASE="/SiliconValley/Bay/8824/" HEIGHT=36 WIDTH=256> <PARAM NAME="membername" VALUE="your_member_name"> </APPLET>
You would receive an e-mail message every time a visitor would have entered a page of yours. The message would like the following:
Sent from MailForm posted at: http://geocities.datacellar.net/your_page (visitor) the visitor's internet (DNS) address (time) the time (incl. the TimeZone) of the visit Remote IP: the visitor's IP address
source: MailApplet.java
import java.lang.*; import java.util.*; import java.io.*; import java.net.*; import java.awt.*; import java.applet.*; public class MailApplet extends Applet implements Runnable { TextArea txt; public void init() { txt=new TextArea("Hello ", 2, 60); add(txt); }; public void start() { (new Thread(this)).start(); } public void run() { try { URL urlDocument = getDocumentBase(); String sHost = urlDocument.getHost(); String sLocal = InetAddress.getLocalHost().getHostName(); String sMember = getParameter("membername"); if (sMember == null) sMember = "jkarchev"; //applet author URL urlMail = new URL(urlDocument, "/cgi-bin/homestead/mail.pl?"+sMember); URLConnection postMail = urlMail.openConnection(); postMail.setDoOutput(true); postMail.setDoInput(true); postMail.setRequestProperty("Referer", urlDocument.toString()); postMail.setRequestProperty("Connection", "Keep-Alive"); postMail.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); PrintStream out = new PrintStream(postMail.getOutputStream()); out.print("visitor=" + sLocal); out.print("&time=" + (new Date()).toString().replace(' ', '+')); out.close(); postMail.connect(); txt.appendText(sLocal); DataInputStream in = new DataInputStream(postMail.getInputStream()); while (in.available() == 0); while (in.available() > 0) sLocal = in.readLine(); in.close(); txt.appendText(", I'm " + sMember + "\n"); } catch (Exception e) { txt.appendText(e.toString()); } } }