by Dinesh Thakur

Java allows the applet to transfer the control to another URL by using the showDocument () Method defined in the AppletContext interface. For this, first of all, it is needed to obtain the Context of the currently executing applet by calling the getAppletContext () method defined by the Applet. Once the context of the applet is obtained with in an applet, another document can be brought into view by calling showDocument () method.

There are two showDocument () methods which are as follows:

showDocument(URL url)

showDocument(URL url,string lac)


url is the URL from where the document is to be brought into view.

loc is the location within the browser window where the specified document is to be displayed.

Example An applet code to demonstrate the use of AppletContext and showDocument ().

import java.applet.Applet;

import java.applet.AppletContext;



<applet code="LoadHTMLFileSample" width="700" height="500"></applet>


public class LoadHTMLFileSample extends Applet


    public void start()


          AppletContext context= getAppletContext();

          //get AppletContext

          URL codeBase = getCodeBase(); //get Applet code base


                 URL url = new URL(codeBase + "Test.html");



               }catch(MalformedURLException mfe) {