The Java Program: Switch.java
1 // Switch.java
2
3 import java.net.URL;
4 import java.net.MalformedURLException;
5 import java.awt.Graphics;
6 import java.applet.Applet;
7
8 public class Switch extends Applet {
9 URL target = null;
10 public void init() {
11 String x = getParameter("target");
12 if (x == null) {
13 x = "http://www.cs.fit.edu/~ryan/index.html";
14 }
15 try {
16 target = new URL(x);
17 } catch (MalformedURLException e) {}
18 }
19
20 public void paint(Graphics g) { }
21
22 public void start() {
23 getAppletContext().showDocument(target);
24 }
25 }
26
27
28 /*
29
30 Put this in a HTML document which should automatically
31 switch to a Java powered document if viewed by a Java
32 enabled browswer
33
34 <applet code="switch.class" width=2 height=2>
35 <param name="target" value="Your-javatized-page-URL">
36 </applet>
37
38 */