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.

130 webMathematica User GuideIf[ $$fullDate === "true",DateString[],DateString[{"Hour", ":","Minute",":","Second"}]]There is one evaluation carried out by Mathematica; this checks the setting of the fullDateinput parameter (which came from the checkbox in the original web page). It returns a string ofthe date.Note how the page does not need any HTML formatting because the result is just a string thatis used by the loadDate() JavaScript function. Also, note how the page displayed in thebrowser does not change; only part of the page changes. This can help to improve performance,since less is transmitted. Also, it can improve appearance since the whole page doesnot flicker. Another benefit is that other effects can be added, for example, while the browser iswaiting for the result to come back it could do something to indicate that the page is waiting forsomething.HTML ExampleAJAX techniques are not limited to string results from the server. In fact, the server can returnwith many differrent types of format, and these can be used to change the contents of thedocument in the browser. This example shows how the src attribute of an img tag can bechanged.The source for this example can be found in the webMathematica web application in the directoryExamples/AJAX (the full path in Tomcat would be webapps/webMathematica/Examples/AJAX). The two files are LoadImage.jsp, which contains the AJAX code to call to the server, andReturnImage.jsp, which returns the result from the server. If your server is configured andrunning you can test this example with the URL http://localhost:8080/webMathematica/Examples/AJAX/LoadImage.jsp. (You may have some other URL for accessing your server.)First, this is the source of ReturnImage.jsp, which is similar to ReturnDate.jsp except that itreturns an HTML fragment (this is done with MSPShow); it also sets the content type to betext/xml.

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

Saved successfully!

Ooh no, something went wrong!