11.07.2015 Views

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

42 webMathematica User GuideA form element is a block of HTML that may contain input elements. A form may be activatedwith an input of type submit; this sends the name and value associated with each input tag tothe server. Here, the opening tag of the form element contains two attributes. The actionattribute refers to a URL that is accessed when the form is activated. In this case, it is a relativeURL that refers to the original Variables script. The method attribute tells the browser whatHTTP method to use, in this case, a post method. (It is very common to use post methods.)This example has two input tags: the first allows the user of the page to enter text, and thesecond specifies a button that, when pressed, will submit the form. When the form is submitted,it will send information from input elements to the URL specified by the action attribute(in this case, the same JSP). Text entered into the input tag, which uses the name tmp, will beassigned to the input variable $$tmp.The first time the page is accessed there is no value for $$tmp. When a value is entered in thetext field and the Evaluate button pressed, $$tmp gets a value that is displayed. Note that thevalue is a Mathematica string~if you try and enter a computation such as "5+7", no computationis actually done. If you want the input to be interpreted and evaluated by Mathematica,you need to use one of the MSP functions.Note that the $$ prefix is used to label input variables; these are variables that are sent withthe HTTP request. The use of variables is discussed further in Tips and Tricks: Variables.MSP Functions: Expand.jspIf you installed webMathematica as described above, you should be able to connect to this JSPvia http://localhost:8080/webMathematica/Examples/Expand.jsp. (You may have some otherURL for accessing your server.)When the submit button is pressed, the polynomial is raised to the power and expanded, andan HTML page that contains the result is returned. The source for this page is in webMathematiÖca/Examples/Expand.jsp. A section that shows the form tag is shown below.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!