WEBMATHEMATICA TUTORIAL

Debugging webMathematica

webMathematica involves running computations inside a server. This poses a number of problems and constraints for investigating why it does not work as you intend. The best way to track down issues is to use Wolfram Workbench to connect to the server and debug your code.

Not Using Wolfram Workbench

If you do not want to use Wolfram Workbench, you can use messages and print statements to resolve your problems. You can get message output returned in your web page with MSPGetMessages and the output of print statements with MSPGetPrintOutput. The capture of message and print output is described in the example Messages.jsp. It is probably a good idea to confirm that your calculations work correctly in an interactive Mathematica session.

In addition to message and print output, you can use the logging and monitor features provided by the system. These are described in more detail in the sections on Logging and the Kernel Monitor. The simplest technique is to look at the files written by the servlet engine. A more sophisticated way is to use the monitor, which can be accessed via a URL, for example, http://localhost:8080/webMathematica/Resources/Tools/KernelMonitor.jsp. If you increase the level of log output by setting VerboseLogs to true, you will generate more output.

Using Wolfram Workbench

You can use Wolfram Workbench to debug your Mathematica code as it runs in the server. With this you can do things such as set breakpoints, examine the stack, and catch messages. In this way you can gain a deeper understanding of how your code runs, thereby helping you to develop more quickly. You can do this for code loaded into a JSP and for code that runs as a web service. For more information, see the debugging with the Workbench sections of the documentation.

New to Mathematica? Find your learning path »
Have a question? Ask support »