Java Reference
In-Depth Information
Sending Email: Browser Version
Problem
You want an applet to permit the user to compose and send email, but hide your email ad-
dress.
Solution
One approach is to use a mailto: URL hidden in some Java code. This is a somewhat
heavyweight approach—you could do this with a shorter piece of JavaScript code—but this
is the Java Cookbook , and this is one of the places where Java applets remain useful.
Discussion
Because most web browsers are now configured with either built-in or connected email cli-
ents, you can use the mailto: URL as a poor-person's email composer to have users contact
you. Many people prefer this to a fill-in-the-blank “mail” form connected to a script or ser-
vlet because they can use a specialized tool and save their own copy of the mail either in
their log file or by CC'ing their own account. Although you could use a mailto: URL direc-
tly in HTML, experience suggests that a species of parasite called a spam perpetrator will at-
tach itself permanently to your mailbox if you do:
<h1>
<h1> Test </h1>
<p> Here is how to <<a
href= "mailto:spam-magnet@somedomainnamehere.com?subject=Testing Mailto URL
&amp;cc=dilbert@office.comics" > contact us </a>
</h1> <p>
</a>
(The href line should be written as one long line in a real HTML file; the &cc is intention-
ally expanded as an HTML entity inside the href attribute).
My approach is to hide the mailto: URL inside a Java applet, where spam perps are less
likely to notice it. The applet uses showDocument() to activate the mailto: URL:
String theURL = "mailto:" + username;
URL targetURL = new URL(theURL);
getAppletContext.showDocument(targetURL);
Search WWH ::




Custom Search