This is documentation for an earlier version of webMathematica.
View current User Guide (Version 3.3)

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">

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"]
   MSPBlock[ {$$fun, $$x1},
      MSPShow[ Plot[$$fun, {x, 0, $$x1}]]]

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


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.