Mathematica 9 is now available
3.7 Getting Messages: Messages.jsp

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" %>

<html>
<head>
<title>Messages and Print Output</title>
</head>
<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>

<msp:allocateKernel>
<h4>Input is 1/0</h4>

<msp:evaluate>
   Random[]/0
</msp:evaluate>

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

<msp:evaluate>
   Sin[x, 1]
</msp:evaluate>

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

<msp:evaluate>
   Print[ "The result is ", x^2]
</msp:evaluate>

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

<msp:evaluate>
   ColumnForm[ MSPGetMessages[]]      messages displayed here
</msp:evaluate>

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

<msp:evaluate>
   ColumnForm[ MSPGetPrintOutput[]]   print output displayed here
</msp:evaluate>

<hr>
</msp:allocateKernel>
</body>
</html>

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.



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT. CURRENT WEBMATHEMATICA DOCUMENTATION IS NOW AVAILABLE.