Once you have installed and configured a web*Mathematica* server so that the examples run correctly and have studied the basics of writing material for web*Mathematica*, as described previously, you are ready to start developing your own material.

One way to start is to make your own area in the web*Mathematica* web application. You could make a directory here (for example NewScripts) and copy one of the samples (for example Plot.jsp) from the Examples directory. You could then access this script with the URL http://localhost:8080/webMathematica/NewScripts/Plot.jsp.

This might be a good time to revisit the web*Mathematica* index page found at http://localhost:8080/webMathematica/index.html, which provides a number of links that demonstrate features of web*Mathematica*. When you actually want to write your own material, you may look at the Tips and Tricks described in this chapter. The chapter continues to describe other page development utilities that are part of web*Mathematica*.

Wolfram *Workbench* provides tools for developing solutions and applications based on Wolfram products such as *Mathematica* and grid*Mathematica*, http://www.wolfram.com/products/workbench. It also includes support for web*Mathematica*.

More information can be found in the *Workbench* documentation, but the following gives a summary of some of the main features.

Wolfram *Workbench* is a project-based system, and to work with web*Mathematica* it supports a type of web*Mathematica* project. This allows you to develop your web pages and *Mathematica* code, perhaps archiving it in a code repository. You can test the individual components, and then deploy them to the server to actually use them.

Wolfram *Workbench* provides a variety of syntax support for JSP pages. This includes showing both XML, HTML, and JSP syntax errors. Of particular value are reports on *Mathematica* syntax errors inside of evaluate tags.

Wolfram *Workbench* provides a number of tools that help writing JSP and HTML pages. These include command completion and preview features. In addition, a palette is provided that allows templates for entire page structures to be added.

Wolfram *Workbench* offers a number of wizards for creating web*Mathematica* material such as an entire project or a new web page.

Wolfram *Workbench* contains a tool that works with the actual server. From this you can carry out tasks such as starting or stopping the server, deploying your project, and connecting with a debug session.

Wolfram *Workbench* contains the web*Mathematica* user guide, along with other material specific to the *Workbench* tools. This is probably the most convenient way to read the documentation.

Wolfram *Workbench* provides a debugger for *Mathematica* code. You can use this debugger to connect to the server and follow your code as it executes, setting breakpoints to halt in particular locations.

This section provides a summary of a few issues that will help you to get started writing your own pages. These are all described in more detail in later sections of the documentation, but are collected together here in a brief description. Getting a good grasp of these points will help you to make progress in developing your site.

There are two types of variables that are important for you to understand when you are getting started with web*Mathematica*: input variables and page variables.

Input variables come with the HTTP web request, for example from an input field in an HTML form. You can identify input variables in *Mathematica* code because they are labeled with a '$$' prefix. In the example below, the setting variable may be sent from an input field. In *Mathematica* code it is called $$setting.

<input type="text" name="setting" />

<msp:evaluate>

If[ MSPValueQ[ $$setting],

....

]

</msp:evaluate>

You should be aware that input variables are a potential security risk to your server. Therefore, you should always use the special functions, MSPBlock and MSPToExpression, for converting into *Mathematica* input. In particular, you should never use ToExpression on an input variable. An example of using MSPBlock is shown below.

<input type="text" name="fun" />

<msp:evaluate>

MSPBlock[ {$$fun},

Integrate[ $$fun, x]

]

</msp:evaluate>

Page variables are *Mathematica* variables that you use to hold intermediate values. They are called page variables since they are cleared when the page is finished. In the example below, the page variable tmp is used to hold the expression that was entered into the text input field (which is held in an input variable called $$expr). Note the use of the secure function, MSPToExpression, to convert the *Mathematica* expression from the input.

<input type="text" name="expr" />

<msp:evaluate>

tmp = Null;

tmp = MSPToExpression[ $$expr] ;

</msp:evaluate>

<p>

<msp:evaluate>

If[ tmp =!= Null,

....

]

</msp:evaluate>

</p>

If you want your variable to persist from one page to another, you can declare it as a session variable. This and further details of variables are discussed in detail in Advanced Topics: Variables.

The purpose of web*Mathematica* is to use *Mathematica* for web computation; a key part of this is placing *Mathematica* code in your web pages. This is done with evaluate tags, as follows.

<msp:evaluate>

Integrate[ 1/(1-x^3),x]

</msp:evaluate>

Note that the *Mathematica* code will evaluate in the typical way for *Mathematica *and the result of the computation will appear in the web page. You can use MSPFormat to change the way that the result is formatted; more information on formatting in web*Mathematica* is found in Advanced Topics: Evaluation Formatting. An example of MSPFormat is shown below; this formats the integral into TraditionalForm using a GIF image to display the result.

<msp:evaluate>

MSPFormat[ Integrate[ 1/(1-x^3),x], TraditionalForm]

</msp:evaluate>

<msp:evaluate>

x = 109;

</msp:evaluate>

A final tip for working with code in web*Mathematica* pages is the separation of multiple computations in a single evaluate tag by using a semicolon ';'. This is shown below.

<msp:evaluate>

x = 109;

y = 44.5;

{x+y}

</msp:evaluate>

More information on coding in web*Mathematica* pages is found in Appendix: MSP Taglib, which gives a detailed reference on the web*Mathematica* tags.

web*Mathematica* provides a number of templates and other utilities that can be used to incorporate more design into your web*Mathematica* material.

The web*Mathematica* examples can be reached from the web*Mathematica* home page, which you should be able to reach via http://localhost:8080/webMathematica. (You may have some other URL for accessing your server.) The home page shows examples wrapped up in a template that adds more design around the pages to give them a better visual appearance. This template makes use of HTML frames and so it would be relatively easy to modify your own work to make use of it.

As you develop your own material, you may wish to look at the design examples. These are a collection of samples that make use of colors, fonts, and images for a more professional appearance. You can access the design examples from the main index page, or with a URL such as http://localhost:8080/webMathematica/DesignTemplates/DesignTemplate1.jsp.

A collection of banners and buttons are available for use in your pages, which you can find with the link http://localhost:8080/webMathematica/BannersImages/. To use one of these images, such as the banner webm-white.gif, you can use an img tag such as the following.

Certain license options for web*Mathematica* require that you use an approved banner for your site. You may use one of these banner images in order to comply with this requirement.

When you have confirmed that your web*Mathematica* site is running correctly and you start to develop your own material, you may wish to strip out all of the documentation and examples to get a minimal installation. The minimum set of files for web*Mathematica* is that everything in the WEB-INF directory must be kept.

In addition you can remove all the *J/Link* native libraries from webMathematica/WEB-INF/lib/SystemFiles/Libraries except for the library required for your system, which is located in a directory named by $SystemID.