Documentation![]() ![]() |
![]() ![]() ![]() |
この例ではMathematica が生成するメッセージやプリント出力がWebのページに返される仕組みを説明します.前述のようにwebMathematica をインストールするとhttp://localhost:8080/webMathematica/Examples/Messages.jspでこのJSPに接続することができます(ご自分のサーバに接続するURLはこれとは多少異なる場合もあります).このページのソースは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[]] メッセージはここに表示される
</msp:evaluate>
<hr><p>The print output was:</p>
<msp:evaluate>
ColumnForm[ MSPGetPrintOutput[]] プリント出力はここに表示される
</msp:evaluate>
<hr>
</msp:allocateKernel>
</body>
</html>
内容は極めて単純です.メッセージを生成する評価は2つだけです.メッセージの後ろにMSPGetMessagesとMSPGetPrintOutputが続きます.両方ともColumnFormでフォーマットされます.生成されたメッセージが結果のページに表示されます.
![]() ![]() ![]() |