42
<%@ page language="java"  %>
<%@ taglib uri="/webMathematica taglib" prefix="msp" %>
Assigning Variables

Assigning Variables

html form
 
Enter something:

field for user input


$$tmp
evaluated by Mathematica

value="Evaluate" /> 
button for activating form
 
This page is more elaborate because it contains form and input elements. These are important ways for allowing
interaction from the client.
A form element is a block of HTML that may contain input elements. A form may be activated with an input
of type submit; this sends the name and value associated with each input tag to the server. Here, the opening tag
of the form element contains two attributes. The action attribute refers to a URL that is accessed when the form
is activated. In this case, it is a relative URL that refers to the original Variables script. The method attribute tells
the browser what HTTP 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  the  second  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 be assigned to the input variable $$tmp.
The first  time the  page  is accessed  there is  no value for  $$tmp.  When  a value  is entered  in the text field  and the
Evaluate button pressed, $$tmp gets a value which is displayed. Note that the value is a Mathematica string if
you try and enter a computation such as "5+7", no computation is actually done. If you want the input to be inter 
preted  and  evaluated  by  Mathematica,  you  need  to  use  one  of  the  MSP  functions  that  are  described  later  in  this
chapter.
Note that the $$ prefix is used to label input variables; these are variables that are sent with the HTTP request. The
use of variables is discussed further in 
Tips and Tricks: Variables
.
 .
<





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