WEBMATHEMATICA TUTORIAL

Including Static Files

webMathematica involves returning dynamically generated material. However, the web pages that webMathematica generates may include static images, which might have been generated by a designer. webMathematica comes with a number of images, such as banners and buttons, which you may use. This section discusses how webMathematica pages can use static files. It will focus on image files, but the principles apply in general to other files.

Images are placed in HTML pages with an img tag. It is convenient for these tags to use a relative URL to refer to the server from which the HTML page originated. Web pages that use relative URLs are easy to move from one server to another. There are two types of relative URLs: those that start with a '/' character and those that do not. The following URL starts with a '/' character.

<img src="/webMathematica/Resources/Images/webm-white.gif" />

If webMathematica returns an HTML page containing this URL, the browser will try to load the image from the Images directory within the webMathematica web application. The servlet container is capable of returning this image, which should appear correctly. If these image requests do not work and you are using a servlet container as a backend to another web server, you should make certain that it forwards requests for images to the servlet engine.

An alternative is a relative URL that does not start with a '/' character. For example, an HTML page, which is generated by a URL such as http://server/webMathematica/Demo/Test.jsp, may contain an img tag such as the following.

<img src="folder/bullet.gif" />

In this case, the browser will try to retrieve the image with the URL http://server/webMathematica/Demo/folder/bullet.gif, which can be processed by the servlet container to return the appropriate image file. This is convenient because you can place images and JSPs together in the same directory.