Message Boards Message Boards

0
|
9395 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Is it possible to send MathML from a browser to webMathematica?

Posted 10 years ago

A simple pair of JSPs... The first is a simple example client based on the LoadXML.jsp.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://www.wolfram.com/msp" prefix="msp" %>
<html>
<head>
    <title>MathML Client</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="shortcut icon" href="../../Resources/Images/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="../../Resources/CSS/webMathematica.css" />
    <script type="text/javascript" src="../../Resources/JavaScript/webMathematica.js"></script>

    <script>
        function submitStep() {
            var xmlHttp;
            try { // Firefox, Opera 8.0+, Safari  
                xmlHttp = new XMLHttpRequest();
                if (xmlHttp.overrideMimeType) {
                    xmlHttp.overrideMimeType('text/xml');
                }
            } catch (e) {
                // Internet Explorer  
                try {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) {
                        alert("Your browser does not support AJAX!");
                        return false;
                    }
                }
            }
            xmlHttp.onreadystatechange = function () {
                if (xmlHttp.readyState == 4) {
                    console.dir(xmlHttp);
                    document.getElementById("result").innerHTML = xmlHttp.response;
                }
            }
            var url = "MathMLServer.jsp";
            var step = '<math> <mn> 4 </mn> <mfenced> <mrow> <mi> y </mi> <mo> - </mo> <mn> 5 </mn> </mrow> </mfenced> <mo> - </mo> <mn> 3 </mn> <mi> y </mi> <mo> = </mo> <mo> - </mo> <mn> 1 </mn> </math>';

            url = url + "?step=" + encodeURIComponent(step);
            xmlHttp.open("POST", url, false);
            xmlHttp.send(null);
        }
    </script>
</head>

<body>
    <div class="container_noborder">
        <div class="section">
            <h1>MathML Test Page</h1>
        </div>
        <div class="section">
            <button onclick="submitStep()">Submit Step</button>
        </div>
        <div class="section">
            <span id="result"></span>
        </div>
        <p class="description">
            A basic AJAX example that submits MathML to the server.
        </p>
    </div>
    <h3>Messages</h3>
    <msp:evaluate>
        ColumnForm[MSPGetMessages[]]
    </msp:evaluate>
    <h3>Prints</h3>
    <msp:evaluate>
        ColumnForm[MSPGetPrintOutput[]]
    </msp:evaluate>
</body>
</html>

The MathML in step above validates and renders fine on Wolfram's MathMLCentral.com.

And here is the server JSP MathMLServer.jsp...

<%@ page contentType="text/xml"%> 
<%@ taglib uri="http://www.wolfram.com/msp" prefix="msp" %>
<msp:evaluate>
    If[ MSPValueQ[ $$step ],
        step = MSPToExpression[ $$step ];
    ]
    MSPFormat[step, StandardForm]
</msp:evaluate>

webMathematica returns...

HTTP Status 403 - Value "<math> <mn> 4 </mn> <mfenced> <mrow> <mi> y </mi> <mo> - </mo> <mn> 5 </mn> </mrow> </mfenced> <mo> - </mo> <mn> 3 </mn> <mi> y </mi> <mo> = </mo> <mo> - </mo> <mn> 1 </mn> </math>" of input "$$step" contains disallowed symbols.
type Status report

message Value "<math> <mn> 4 </mn> <mfenced> <mrow> <mi> y </mi> <mo> - </mo> <mn> 5 </mn> </mrow> </mfenced> <mo> - </mo> <mn> 3 </mn> <mi> y </mi> <mo> = </mo> <mo> - </mo> <mn> 1 </mn> </math>" of input "$$step" contains disallowed symbols.

description Access to the specified resource has been forbidden.

Apache Tomcat/8.0.24

Any ideas would be appreciated.

Jim

POSTED BY: Jim Van Riper
Posted 10 years ago

I've done some experimentation and it seems that the MSP security code blocks equal signs. I guess someone felt that equal signs never occur in mathematics?

<%@ page contentType="text/xml"%> 
<%@ taglib uri="http://www.wolfram.com/msp" prefix="msp" %>

<msp:evaluate>
    $$step = "<math> <mi>x</mi> <mo>=</mo> <mn>42</mn> </math>";
    MSPBlock[ {$$step}, $$step]
</msp:evaluate>

I've tried different ways to express equal include &#61; and &equals; but the result is the same. Unfortunately the MSPBlock documentation (http://reference.wolfram.com/workbench/index.jsp?topic=/com.wolfram.eclipse.webmathematica.help/html/ref/MSPBlock.html) isn't helpful.

I think this means I need to bypass the webMathematica security system. I'll update as I figure out more for when someone in the future runs into this.

PS, there is a bug in the forum that ignores the code tag within paragraphs. The two equal signs above are supposed to display as & # 6 1 ; and & e q u a l s ; without the extra spaces. They both render correctly in the Post Preview but when the post is saved they get turned into equals.

POSTED BY: Jim Van Riper
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract