Home > JavaSketchpad > About JavaSketchpad > How JavaSketchpad Works

How JavaSketchpad Works

When you look at a Web page that includes a JavaSketch, many components are interacting behind the scenes to bring Dynamic Geometry to your desktop. The following illustration diagrams the typical set of interactions required to create a JavaSketchpad (JSP) triangle in your Web browser.

Place the Java applet jsp5.jar next to the HTML page

The right side of the illustration represents your Web browser, which is viewing a Web site that contains a JavaSketchpad triangle. When you visit this page, your browser establishes a connection with a remote machine (the Web server), using a URL to specify both the name of the host machine on the Internet and the name and location of the Web page, located on that machine, that you wish to view. In this case, the host Web page is the file triangle.htm, which is located on the server. (Whether you specify the location of the host Web page by typing in a URL or by linking to it from some other page is immaterial; the JavaSketchpad process begins once a connection is forged between your Web browser and a Web server's Web page.)

An arbitrary HTML file on the server may contain text, colors, images, etc., all of which will appear on your browser as the page is loaded. In this example, the triangle.htm file may contain text or pictures, but the important part of its contents for our purposes is that it contains a JavaSketchpad description of a triangle. This description contains two parts: the geometric construction of the triangle itself (written in JavaSketchpad's internal construction language) and a reference to the JavaSketchpad applet, which is the software technology that your Web browser needs in order to visualize the triangle described by the geometric construction. The Web page provides your browser with a reference to the JavaSketchpad applet in the form of a (relative) URL that identifies the directory on the Web server where the applet is located.

When your browser receives this two-part description, it first decides whether it is capable of displaying Java applets or not. Older browsers don't understand Java, so they give an error message and the process stops. Java-capable browsers, on the other hand, must download the JavaSketchpad applet so that it can run inside your Web browser. Using the applet's URL, your browser connects to the Web server and downloads the JSP applet.

Once the applet has been downloaded (and is "resident" in your browser), your browser passes the geometric description of the triangle contained in the original triangle.htm file. JavaSketchpad starts executing and displays the dynamic triangle specified by this geometric description. At this point, the process is complete: You can begin interacting with the triangle (and with the JavaSketchpad applet that displays it).

If you go on from the triangle Web page to look at other Web pages on the server, such as pythag.htm (perhaps by following a link to them from triangle.htm), chances are your Web browser is smart enough to realize that you've already downloaded the JavaSketchpad applet and don't need to download the applet file again.  If so, you only pay the penalty of downloading the applet once. But when you quit your browser or move to some other page that no longer contains a JavaSketchpad illustration, chances are your browser will flush the JavaSketchpad applet from its memory. So the next time you visit a JavaSketchpad Web page, you'll have to wait for the applet to download again before the page's JavaSketchpad illustrations become available.

Publishing Your Own JavaSketches

If you want to create your own Web pages containing JavaSketches, you'll need access to a Web server on which you can place your pages (HTML files) and the applet itself (the .jar file). Simply download the applet from the Download Center, expand the download, and place the applet in the directory on your server where you keep your Web pages. (Note that you must not rename the jsp5.jar file)

As described in the following two sections, you have two options for creating Web pages (HTML files) containing constructions that can be displayed by the JavaSketchpad applet.

Creating JavaSketches Automatically

If you own a copy of The Geometer's Sketchpad version 5 for Macintosh or Windows desktop computers, you can create your sketches using a full set of interactive drawing, construction, and formatting tools. This is by far the preferred method for building JavaSketches. You can convert sketch files saved from The Geometer's Sketchpad into HTML pages that contain the appropriate geometric description and applet invocation information by choosing Save As and, in the Save As dialog box, choosing the HTML/JavaSketchpad format.

There's one caution that you need to observe if you create sketches using The Geometer's Sketchpad. As explained above, each HTML file contains a relative URL to the location of the applet, so that Web browsers looking at your Web page can find where the .jar file lives on your Web server. When Sketchpad creates an HTML file from a Sketchpad sketch, it places the JSP applet next to the HTML file and assumes that you will store both of these files in the same directory on your server (i.e., that you will place the HTML file in the directory that contains the JSP applet before you attempt to view it in a Web browser). Thus the converted HTML file contains a relative URL to the applet that looks like the following:

This tag indicates that a browser should download the JavaSketchpad applet from the same directory as the Web page that is currently being viewed by the browser. If you decide to store the Web page anywhere other than in the directory containing the JSP applet, you'll need to modify the converted HTML's CODEBASE tag so that it contains a valid relative path from the HTML file to the JSP applet.

Of course, it's easier not to change the CODEBASE tag, and simply to keep all of your JavaSketch HTML files in the same directory as the JSP applet.

Once you've saved a sketch as a Web page, you can add to or alter the Web page's non-Java contents however you see fit. There are many tools, like Microsoft FrontPage or Claris Home Page, that can help you with this.

Creating JavaSketches Manually

If you don't own The Geometer's Sketchpad or are interested in generating JavaSketchpad visualizations that cannot be created by desktop Sketchpad, you can create your own HTML files from scratch (using a text editor or a Web-page layout program). However, you'll need to learn JavaSketchpad's internal construction language in order to do so. This semi-human-readable language is simple enough that you should be able to put together elementary constructions without using The Geometer's Sketchpad. Alternatively, if you are using Mathematica or other software to explore geometric shapes, you may be able to teach the software you routinely use to "speak" JavaSketchpad's construction language. Once you've done that, you'll be able to use the JavaSketchpad applet to investigate and manipulate geometric objects created using your primary software tools.

Visit the Developer's Grammar to learn about the JavaSketchpad construction grammar.