Java Reference
In-Depth Information
Further, I break the email address into two parts and provide the @ separately, so it won't be
seen as an email address even if the spam-spider is clever enough to look into the param
parts of the applet tag. Because I know you won't actually deploy this code without chan-
ging Target1 and Target2 —the param tags for the mail receiver's email name and host do-
main—you're fairly safe from spam with this. Example 17-1 is the Java applet class.
Example 17-1. MailtoButton.java
public
public class
class MailtoButton
MailtoButton extends
extends Applet {
private
private static
long serialVersionUID = - 3186706180199804315L ;
/** The label that is to appear in the button */
protected
static final
final long
protected String label = null
null ;
/** The width and height */
protected
protected int
int width , height ;
/** The string form of the URL to jump to */
protected
protected String targetName , targetHost ;
/** The URL to jump to when the button is pushed. */
protected
protected URL targetURL ;
/** The name of the font */
protected
protected String fontName ;
protected
protected String DEFAULTFONTNAME = "helvetica" ;
/** The font */
protected
protected Font theFont ;
/** The size of the font */
protected
protected int
int fontSize = 18 ;
/** The HTML PARAM for the user account -- keep it short */
private
private String TARGET1 = "U" ; // for User
/** The HTML PARAM for the hostname -- keep it short */
private
private String TARGET2 = "H" ;
// for Host
// Dummy
//private String BOGON1 = "username"; // happy strings-ing, SPAM perps
//private String BOGON2 = "hostname"; // ditto.
/** The string for the Subject line, if any */
private
private String subject ;
/** Called from the browser to set up. We want to throw various
* kinds of exceptions but the API predefines that we don't, so we
* limit ourselves to the ubiquitous IllegalArgumentException.
*/
public
public void
void init () {
// System.out.println("In LinkButton::init");
try
try {
iif (( targetName = getParameter ( TARGET1 )) == null
null )
throw
throw new
new IllegalArgumentException (
Search WWH ::




Custom Search