Re: Call a Rexx Script from a Web Page
- From: "Salvador Parra Camacho" <sparrac@xxxxxxxxx>
- Date: 17 Jul 2006 13:22:38 -0700
Alex ha escrito:
Can you use server-side scripting locally? ...
I was hoping to avoid the complexity of using a web server, local or
not.
Some web servers can be configured quickly and CGI programming is
easy. web/2 is a good example:
1. Download it from http://dink.org/files/web2win32beta3.zip.
2. Extract the ZIP contents into a directory.
3. Execute "setup.exe" and change the default web port from 80 to
8080.
4. Edit the "cgi.cfg" file adding the DOS path to your interpreter:
"C:\ARCHIV~1\ApDev\langs\orexx\ooRexx\rexx.exe .rex"
5. Put your HTML files in ".\html".
6. Put your REXX CGIs in ".\cgi-bin".
7. Create the following "start.cmd" file in web/2 directory:
@echo off
start "Web server" /min web.exe
start http://localhost:8080
Now you have a web server ready for REXX CGI programming. Your
application now works with every web browser (in fact, "start.cmd"
starts the default browser, not MSIE): Internet Explorer, Firefox,
SeaMonkey, Netscape, Opera, Links...
Pros: web browser and platform independent, can be used for remote
applications, easy programming.
Cons: this method needs a web server.
As sample HTML file:
<!-- form_server.html -->
<html>
<head>
<title>Server-side REXX web application</title>
</head>
<body>
<h1>Server-side REXX web application</h1>
<form name="form_server" id="form_server"
method="post" action="cgi-bin/form_server.rex"
onsubmit="" onreset="">
<p>Text field: <input type="text" name="text" /></p>
<p>Password: <input type="password" name="password" /></p>
<p>Selection:
<select name="selection">
<option> REXX </option>
<option> Object REXX </option>
<option> NetREXX </option>
</select>
</p>
<p>Textarea: <textarea name="area" rows="5"
cols="20"></textarea></p>
<input type="submit" value="Send" />
<input type="reset" value="Clear" />
</form>
</body>
</html>
As sample REXX file:
/* form_server.rex */
say 'Content-type: text/html'
say
method = value('REQUEST_METHOD', , 'ENVIRONMENT')
length = value('CONTENT_LENGTH', , 'ENVIRONMENT')
if method = 'GET' then do
query_string = value('QUERY_STRING', , 'ENVIRONMENT')
end
if method = 'POST' & length <> '' then do
post_string = charin(, , length)
query_string = post_string
end
say '<html>'
say '<head>'
say '<title>Server-side REXX web application output</title>'
say '</head>'
say '<body>'
say '<h1>Server-side REXX web application output</h1>'
if query_string = '' then
say '<em>No input data</em>'
do while query_string <> ''
parse var query_string data '&' query_string
say '<p>' || data || '</p>'
end
say '</body>'
say '</html>'
exit
The June 22 post by Rainer titled "get result of oorexx script
into frame" at
http://groups.google.com/group/comp.lang.rexx/msg/cc8fbd653c658b69
looks more like what I have in mind.
The script in my html need only call a Rexx program (on my machine)
with an argument to say which button or link was clicked, and then use
document~writeln(<new page html returned>) to display the new page in
Internet Explorer. (I can handle that much oo code. :-) Thanks.
The client-side approach using Internet Explorer as WSH (Windows
Scripting Host) and Object REXX as WSE (Windows Scripting Engine)
doesn't depend on a web server, but is harder to program (IMHO). See
the Rony example.
As additional advantage, you can convert your web application in a
HTA application and then you can tokenize your code to protect it
(unlike JavaScript).
As sample HTML file:
<!-- form_client.html -->
<html>
<head>
<title>Client-side REXX web application</title>
<script language="Object REXX" src="form_client.rex"></script>
</head>
<body>
<h1>Client-side REXX web application</h1>
<form name="form_client" id="form_client"
method="" action=""
onsubmit="return handle_form(this);" onreset="">
<p>Text field: <input type="text" name="text" /></p>
<p>Password: <input type="password" name="password" /></p>
<p>Selection:
<select name="selection">
<option> REXX </option>
<option> Object REXX </option>
<option> NetREXX </option>
</select>
</p>
<p>Textarea: <textarea name="area" rows="5"
cols="20"></textarea></p>
<input type="submit" value="Send" />
<input type="reset" value="Clear" />
</form>
</body>
</html>
As sample REXX file:
/* form_client.rex */
::routine handle_form public
use arg form
document~writeln('<html>')
document~writeln('<head>')
document~writeln('<title>Client-side REXX web application
output</title>')
document~writeln('</head>')
document~writeln('<body>')
document~writeln('<h1>Client-side REXX web application
output</h1>')
document~writeln('<p>' form '</p>')
/* Unfortunatly I can't extract the values of the form with the
usual
JavaScript methods of the Form object. The output truncates
here
if I try call some of this methods... and there aren't any
"JavaScript"
warning. -Open Object REXX 3.1 beta 1-
Suggestions?
*/
document~writeln('</body>')
document~writeln('</html>')
return .false -- prevents the submision of the form
You can convert this web application in a HTA application easily
changing the name of "form_client.html" to "form_client.hta". And
adding the special tag "hta:application" you can also set some
properties of this application. Following, an example:
<hta:application
id="MyCoolApplication"
applicationname="My Cool Application"
singleinstance="yes"
border="dialog"
contextmenu="no"
icon="form_client.ico"
innerborder="no"
maximizebutton="no"
scroll="no"
selection="no"
version="1.0"
/>
Best regards:
Salvador Parra Camacho
.
- References:
- Call a Rexx Script from a Web Page
- From: Alex
- Re: Call a Rexx Script from a Web Page
- From: Salvador Parra Camacho
- Re: Call a Rexx Script from a Web Page
- From: Alex
- Call a Rexx Script from a Web Page
- Prev by Date: Re: Call a Rexx Script from a Web Page
- Previous by thread: Re: Call a Rexx Script from a Web Page
- Next by thread: Re: Call a Rexx Script from a Web Page
- Index(es):