
7.3.2 Scrivere i parametri del dispositivo utilizzando form
Uno degli aspetti più importanti delle comunicazioni Ethernet tra
“server” e “client” Web è dato dalla possibilità di includere funzioni
interattive. Il modo più semplice per farlo è quello di utilizzare delle
“form”.
Le form non sono altro che dei moduli utilizzati nelle pagine Web per
raccogliere informazioni dagli utenti del browser.
Attraverso una form il client può inviare informazioni al server
utilizzando oggetti di immissione come ad esempio caselle di testo,
menù, caselle di controllo e così via.
In questo capitolo, dopo una breve introduzione degli elementi di base
di una form, vi mostreremo come utilizzarle per leggere e scrivere sia i
parametri del WebGate che il valore di uno o più variabili del
dispositivo collegato al Webgate.
Come vengono elaborati i contenuti di una form dal server dopo che il
client ha inviato le informazioni? Generalmente un programma interno
al server, come ad esempio il CGI (Common Gateway Interface) o
[N/I]SAPI (Netscape/Internet Server Application Program Interface),
analizza le informazioni inviate.
Dal momento che il WebGate non è dotato di programma CGI
integrato, analizza i dati in tempo reale utilizzando i comandi GET o
POST e trovando le informazioni all’interno dei comandi stessi.
Una volta immesse le informazioni in una form, questa viene inviata al
server utilizzando la funzione “Submit”. In alternativa, la form che non è
ancora stata inviata, può essere riportata ai valori originali utilizzando
la funzione “Reset”. Queste due funzioni, “Submit” e “Reset”, sono
elementi standard nelle form delle pagine Web. Per maggiori
informazioni sull’utilizzo e la sintassi di queste due funzioni, potete
consultare la documentazione disponibile sull’HTML.
7.3.2.1 Gli attributi della form
Gli attributi della form sono name, method e action:
Attributi del form
name
method
action
Tab. 7.3.2.1.1
Ad esempio: <form name="form4" method="post"
action="mypage.htm">.
Gli attributi method e action sono i più importanti al fine del suo
corretto funzionamento.
Attributo ACTION:
Generalmente l’attributo action specifica l’indirizzo
del programma che gestirà i dati all’interno della
form. Di solito è impostato con l’indirizzo di uno
script CGI per la decodifica dei dati. Ad esempio,
il codice
<FORM ACTION = “http://www.myserver.com/cgi-
prog/post-command…> fa riferimento ad uno
script chiamato post-command nella cartella
cgi-prog sul server il cui indirizzo è dato dall’URL
www.myserver.com.
Dal momento che il WebGate non è dotato di
un programma CGI integrato, per
l’elaborazione dei dati, gli unici URL permessi
per questo attributo sono quelli che
indirizzano a pagine precedentemente caricate
(inclusa la pagina con la form), in grado di
visualizzare i risultati dei dati inviati
dall’utente.
Ad esempio:
ACTION = “IR32cold.HTML” o ACTION =
“192.168.10.42/mypage.htm” dove 192.168.10.42
è l’indirizzo IP del WebGate.
7.3.2 Writing device parameters using Forms
One of the most important aspects of the Ethernet communications
between “Web servers” and their “clients” is the possibility to include
interactive features. The easiest way to do it is using “forms”.
Forms are used in Web pages to get information from browser end
users.
By a form the client can send information to the server by using input
objects such as text boxes, menus, check boxes and so on.
In this chapter, after a brief introduction on the basis elements of a
form, you will see how forms can be used for reading and writing both
WebGate’s parameters and the value of one or more variables of the
device connected to the WebGate.
How the contents of a form can be processed by the server once the
client submit the information? Generally a program inside the server, as
CGI (Common Gateway Interface) or [N/I]SAPI (Netscape/Internet
Server Application Program Interface), parses the submitted informa-
tion data.
As WebGate hasn’t any CGI program on board it parses data in real
time using the GET or POST commands, having information data
inside the commands themselves.
Once information has been entered into a form, the form is submitted
to the server. This is accomplished using the “Submit” function.
Alternatively, a form that has not already been submitted can be
restored to its original values using the “Reset” function. These two
functions, “Submit” and “Reset”, are standard HTML form elements that
control forms in Web pages. For information on their use and syntax,
please consult a standard HTML reference.
7.3.2.1 The form attributes
The form attributes are name, method and action:
Form Attributes
name
method
action
Tab. 7.3.2.1.1
For example: <form name="form4" method="post"
action="mypage.htm">.
The second two attributes, method and action, are the most important
to make the form work.
ACTION attribute: Generally the action attribute specify the address of
the program that will handle the data inside the
form. It is usually set to a URL pointing to a CGI
script to decode the data. For example, the code:
<FORM ACTION = “http://www.myserver.com/cgi-
prog/post-command…>
is for a script called post-command in the directory
cgi-prog on the server which address is given by the
URL www.myserver.com.
As WebGate hasn’t any CGI program on board to
parse the data, the only URLs permitted for this
attribute are those pointing to pages previously
loaded (included the page with the form itself),
able to show the effects of the form data sent by
the user.
For example:
ACTION = “IR32cold.HTML” or ACTION =
“192.168.10.42/mypage.htm” where 192.168.10.42
is the IP address of the WebGate.
24
Manuale WebGate - cod. +030220230 rel. 1.0 - 16.09.2003