This is documentation for an earlier version of webMathematica.
View current User Guide (Version 3.3)

Documentation3. Basic Examples


3.7 Getting Messages: Messages.jsp

This example demonstrates how messages and print output generated by Mathematica can be returned in the web page. If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Messages.jsp. (You may have some other URL for accessing your server.) The source for this page is in webMathematica/Examples/Messages.jsp.

<%@ page language="java" %>
<%@ taglib uri="/webMathematica-taglib" prefix="msp" %>

<title>Messages and Print Output</title>
<body text="#171717" bgcolor = "#ffffff">
<h1>Messages and Print Output</h1>

<p>These are some evaluations that will cause messages to be
generated by Mathematica.</p>

<h4>Input is 1/0</h4>


<h4>Input is Sin[x, 1]</h4>

   Sin[x, 1]

<h4>Input is Print[ "The result is ", x^2]</h4>

   Print[ "The result is ", x^2]

<hr><p>The messages were:</p>

   ColumnForm[ MSPGetMessages[]]      messages displayed here

<hr><p>The print output was:</p>

   ColumnForm[ MSPGetPrintOutput[]]   print output displayed here


The contents are very simple; there are two evaluations that cause messages to be generated. These are followed by uses of MSPGetMessages and MSPGetPrintOutput, both of which are formatted by ColumnForm. The messages that were generated are displayed in the resulting page.