Mathematica 9 is now available
3.4 Graphics: Plot.jsp

Documentation3. Basic Examples

 

3.4 Graphics: Plot.jsp

If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Plot.jsp. (You may have some other URL for accessing your server.)

This example generates a plot. The source for this page is in webMathematica/Examples/Plot.jsp. A section that shows the form tag is shown below.

<form action="Plot.jsp" method="post">

<msp:allocateKernel>
Enter a function:
<input type="text" name="fun" size="24" value =
   "<msp:evaluate>MSPValue[ $$fun, "Sin[x]^2"]
      </msp:evaluate>"       remember input settings from one call to the next
/>
Enter a number:
<input type="text" name="x1" size="24" value =
   "<msp:evaluate>MSPValue[ $$x1, "10"]
      </msp:evaluate>"
/>
<br>
<msp:evaluate>
   MSPBlock[ {$$fun, $$x1},
      MSPShow[ Plot[$$fun, {x, 0, $$x1}]]]
</msp:evaluate>
<hr>
</msp:allocateKernel>

<input type="submit" name="btnSubmit" value="Evaluate">

</form>

The example shows the use of the MSP functions MSPBlock and MSPShow. MSPBlock is a programming construct introduced in the previous section. MSPShow takes the Mathematica graphics object from the Plot command and generates a GIF image, which is stored on the server, returning an <img> tag. A further discussion on formatting mathematics and graphics is given in the section on Displaying Mathematics and Graphics. Note how the page uses MSPValue to keep the user input each time the page is used.



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.