guillermo
(JOSÉ GUILLERMO SÁNCHEZ LEÓN)
November 21, 2019, 1:02pm
1
webMathematica: How show an output in a new webPage?
e.g. In Basic Examples—Wolfram Language Documentation
How show the result in a new webpage.
The code of the Expand.jsp example can be found in.
I will apprediate if you modify it to obtain the output in a new webpage.
hmichel
(Hans Michel)
November 21, 2019, 8:21pm
2
Guillermo:
I don’t currently have access to a machine with a webMathematica instance. So I am going to go on pure memory.
Your version
Expand.jsp
<form action="Expand.jsp" method="POST"><p><strong>
Expand <input type="TEXT" name="expr" align="LEFT" size="10"
value="${not empty param.expr ? param.expr : 'x+y' }" />
to the <input type="TEXT" name="num" align="LEFT" size="3"
value="${not empty param.num ? param.num : '4' }" />
power.
</strong></p><table><tr><td><input type="image" src="../images/Template2/compute.gif" name="submitButton" value="Compute" alt="Compute" title="Compute" /></td></tr></table><c:if test="${not empty param.num}"><p><div class="webm-results">Results</div><msp:evaluate>
Get["Cluster`"];
</msp:evaluate><div style="padding: 5px; border: 13px solid #CCC; float: left;"><msp:evaluate>
MSPBlock[{$$expr, $$num},
MSPFormatForCluster[Expand[$$expr^$$num], TraditionalForm]
]
</msp:evaluate></div></p></c:if></form><div style="clear: both;"></div>
I would rewrite as follows:
Expand.jsp
<form action="ExpandResult.jsp" method="POST">
<p>
<strong>Expand
<input type="TEXT" name="expr" align="LEFT" size="10" value="${not empty param.expr ? param.expr : 'x+y' }" /> to the
<input type="TEXT" name="num" align="LEFT" size="3" value="${not empty param.num ? param.num : '4' }" /> power.
</strong>
</p>
<table>
<tr>
<td>
<input type="image" src="../images/Template2/compute.gif" name="submitButton" value="Compute" alt="Compute" title="Compute" />
</td>
</tr>
</table>
</form>
ExpandResult.jsp
<c:if test="${not empty param.num}">
<p>
<div class="webm-results">Results</div>
<msp:evaluate>
Get["Cluster`"];
</msp:evaluate>
<div style="padding: 5px; border: 13px solid #CCC; float: left;">
<msp:evaluate>
MSPBlock[{$$expr, $$num},
MSPFormatForCluster[Expand[$$expr^$$num], TraditionalForm]
]
</msp:evaluate>
</div>
</p>
</c:if>
<div style="clear: both;"></div>
The HTML form element’s action attribute is what helps with the redirection. So you just need another file called “ExpandResult.jsp” You can try this first by having the action on Expand.jsp route to a blank “ExpandResult.jsp” page. Then fill in the page with the parameters and msp calculations.
guillermo
(JOSÉ GUILLERMO SÁNCHEZ LEÓN)
November 22, 2019, 7:44am
3
Dear Hans,
I have followed your instructions but some thing is wrong. The new expand and expandresult are attached (of course txt extension should be removed).
In anycase I think I got your idea.
Thanks
Guillermo
Expand.jsp.txt (1.89 KB)
ExpandResult.jsp.txt (499 Bytes)
hmichel
(Hans Michel)
November 22, 2019, 12:31pm
4
Guillermo:
Did you try just a blank ExpandResult.jsp file? (blank meaning minimum HTML tag so that he file would serve)
What Errors did you get?
Plus your attached ExpandResult.jsp page contains no HTML. Etc…
The first link you provided had no html tag etc..So I did not provide any full code. I assumed you got that part.
I would also remove “<c:if test=”${not empty param.num}“>” and its closing tag
Keep us posted when solved.
Hans
guillermo
(JOSÉ GUILLERMO SÁNCHEZ LEÓN)
November 22, 2019, 1:21pm
5
Hans, it works. I have included a minor change. I have used MSPFormat instead of MSPFormatForCluster.
My intention is to build a more complex case but this is a good starting point
Thank you a lot of
Guillermo