57
3.12 Getting Variables: GetBasic.jsp
If  you  installed  webMathematica  as  described  
above
,  you  should  be  able  to  connect  to  this  JSP  via
http://localhost:8080/webMathematica/Examples/GetBasic.jsp. (You  may have  some other  URL  for accessing  your
server.)
This example passes values computed in a JSP into Mathematica where they are used for computation by Mathemat 
ica.  The  source  for  this  page  is  in  webMathematica/Examples/GetBasic.jsp,  and  a  selection  is  shown
below.
num = Random[Integer, {1,10}]; 
list = Table[ Random[], {num}] ; 
sum = Apply[ Plus, list]/num;
  

The average is <%= dValue %>.

<% for ( int i = 0; i < dArray.length; i++) { %>
<% } %>
<%= dArray[i] %>
 
In  this  example  Mathematica  generates  a  list  of  random  numbers,  and  computes  the  mean.  The  JSP obtains  these
values using the msp:get tag. This has a name attribute, which governs the name of the variable in Java, a type
attribute,  which  governs  the  type  that  will  be  used  in  Java,  and  a  value  attribute,  which  gives  the  Mathematica
expression that must be evaluated. Only reference types such as Object, String, or arrays can be sent with this tag. In
addition the type given in Java must be compatible with the type that Mathematica has sent; if this is not the case,
then  an  exception  will  be  thrown.  The  rules  for  transmission  from  Mathematica  are  that  the  normal  J/Link  type
conversions  will  be  applied,  but  if  none  of  these  applies,  then  the  object  will  be  converted  into  an  object  of  type
com.wolfram.jlink.Expr, a class that is provided by J/Link to represent general Mathematica expressions.
This  particular  example  requires  programming  in  both  Java  and  Mathematica.  It  shows  how  easy  it  would  be  to
incorporate webMathematica into an existing JSP framework.
3.13 Interacting with MSPs: IncludeMSP.jsp
If  you  installed  webMathematica  as  described  
above
,  you  should  be  able  to  connect  to  this  JSP  via
http://localhost:8080/webMathematica/Examples/IncludeMSP.jsp.  (You  may  have  some  other  URL  for  accessing
your server.)
 .
<





New Page 1








Home : About Us : Network : Services : Support : FAQ : Control Panel : Order Online : Sitemap : Contact : Terms Of Service

 

Our web partners:  Jsp Web Hosting  Unlimited Web Hosting  Cheapest Web Hosting  Java Web Hosting  Web Templates  Best Web Templates  Web Design Templates  Interland Web Hosting  Cheap Web Hosting  Filemaker Web Hosting  Tomcat Web Hosting  Quality Web Hosting  Best Web Hosting  Mac Web Hosting

 
 

Virtualwebstudio. Business web hosting division of Vision Web Hosting Inc. All rights reserved

Comcast Web Hosting