Question: I have a Java applet consisting of a wizard-like form with three steps. At the final step, the user can click a "finish" button. I want that button to cause the web browser to navigate to a specific URL.

**Question:** Is there a way to cause the browser to navigate to a specific URL, in such a way that it will work across all modern browsers? My specific browser requirements are FF3+, IE7+, Safari 3+, and Opera 9+. I am using Java 1.5.

Answer: 
From the applet you can simply get the applet context and call [showDocument(url)](http://java.sun.com/javase/6/docs/api/java/applet/AppletContext.html#showDocument(java.net.URL)).

This will navigate away from the current page to the specified URL:

```
getAppletContext().showDocument(url);

```

Additionally you can pass a [target](http://java.sun.com/javase/6/docs/api/java/applet/AppletContext.html#showDocument(java.net.URL,%20java.lang.String)) parameter.

To visit a relative URL you can use:

```
URL url = new URL(getCodeBase().getProtocol(),
                          getCodeBase().getHost(),
                          getCodeBase().getPort(),
                          "/next.html");
getAppletContext().showDocument(url);

```

These work in every major browser since Java version 1.1.
If you're using Java 6 and above, see the [Desktop](http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/desktop_api/) API. That'll drive a browser. However I don't know if the applet security model will interfere with this.

Other than that, I've used [BrowserLauncher2](http://browserlaunch2.sourceforge.net/) with success. Similar caveats apply.