J CGI Scripting
Use (and further develop) the J CGI scripting tools discussed in class which has HTML forms input and processing. Build a demonstration Web page which illustrates the use of these tools.
Following is the J CGI example used in class.
NB. argv is bound to a literal vector of args passed to the j.cgi script.
NB. Parse these args; cutting on the ' ' character producing a boxed list of args.
argv =: < ;. _2 argv,' '
system =: 2 !: 0
read =: 1 !: 1 @ <
stdin =: 3 : 'read 1'
NB. Add cgi code below.
NB. If you are returning a web page the following two lines are required
'Content-type: text/html'
''
'<html>'
'<head>'
'<title>Sample Web Page from a J Script</title>'
'</head>'
'<body bgcolor="ffffff" background="Pictures/tile">'
NB. Display args passed (>argv), " 1 '<br>'
query_string =: system 'printenv QUERY_STRING'
parsed_query =: < ;. _2 query_string , '&'
inputs =: (3 : ' (< ;. _2) y. , ''=''') " 1 > parsed_query
get_field =: 3 : ' > 1 { ((, 1 {. " 1 inputs) i. < y.) { inputs'
'<pre>'
query_string
parsed_query
inputs
get_field 'mi'
get_field 'first'
get_field 'last'
'</pre>'
'</body>'
'</html>'
''