Message Boards Message Boards

0
|
5638 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Sending non-trivial expressions from browser -> webMMA for execution

Posted 10 years ago

I'm trying to send strings from the browser thru a query string for execution in my JSP. The key seems to be ToExpression but it behaves unexpectedly (with the non-trivial example). Here is the JSP...

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

<msp:evaluate>

cmd = MSPToExpression[ $$cmd ];
SetDirectory["../webapps/webMathematica/Examples/AJAX"];
Get["qEval.m"];
resultz = ToExpression[ cmd, InputForm ];
ExportString[
    XMLElement["result", {}, resultz], 
    "XML"
]
</msp:evaluate>

Here is the relevant browser code.

 var cmd='applyState[initializeSession, {{A5A, Null}, defineProblem["SolveFor[4(y-5)-3y=-1,y]", {}, {}, gradeBasicAlgebra]}]' ;

    url=url+ "?cmd="+cmd;

    xmlHttp.open("POST", url, true);

    xmlHttp.send(null);

The result seems to work but I end up with ToExpression's sprinkled thru the result.

{A5A0009$Laura$27072015125906 . state, reProcessLRV}ToExpression[Null, InputForm]{{ToExpression[Null, InputForm], ToExpression[Null, InputForm]}, ToExpression[Null, InputForm], ToExpression[Null, InputForm]}ToExpression[List["<math><mrow><mrow><mrow><mn>4</mn><mo>&#8290;</mo><mrow><mo>(</mo><mrow><mi>y</mi><mo>-</mo><mn>5</mn></mrow><mo>)</mo></mrow></mrow><mo>-</mo><mrow><mn>3</mn><mo>&#8290;</mo><mi>y</mi></mrow></mrow><mo>=</mo><mrow><mo>-</mo><mn>1</mn></mrow></mrow></math>", List[List[y], List[]]], InputForm]ToExpression[Null, InputForm]

If I hardcode the applyState command in the JSP it works great.

Any ideas would be appreciated.

Thanks, Jim

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