An easy way that will allow you to do anything you do in J503 on the Web (same method will work for other J version, but the Step 5 need adjustment for other version):

1. Copy a J503 installation to C:\J_WEB

2. Install Apache - 1.3.39 will work for sure. [ 2.2.6 might need some minor adjustments in the following step.]

3. Modify apache\conf\httpd.conf :

There is a line :

DirectoryIndex index.html index.shtml index.wml ...

Add index.ijs at the end.

4. Add these lines at the bottom of the files:

ScriptAlias /j/ "c:/J_WEB/"
AddType application/x-httpd-ijs .ijs
Action application/x-httpd-ijs "/j/j.exe"

5. Modify J_WEB\system\extras\util\boot.ijs

Delete everything and replace by :

_________________________________________
FILE START HERE
_________________________________________

18!:4 <'z' NB. start in z
boot=: 3 : '0!:0 <jhostpath SYSTEM_j_,PATHSEP_j_,y.'

boot 'system\main\sysenv.ijs'
boot 'system\main\stdlib.ijs'
boot 'system\main\colib.ijs'

NB. =========================================================
3 : 0''
if. IFCONSOLE do.
  boot 'system\main\conlib.ijs'
  boot 'system\extras\util\jadecon.ijs'
else.
  boot 'system\main\winlib.ijs'
  boot 'system\extras\util\jadefull.ijs'
  boot 'system\extras\util\jijs.ijs'
  boot 'system\extras\util\configur.ijs'
  configure_jcfg_ 0
  if. -. IFJIJX_j_ do. newijx_jijs_ 0 end.
end.
)
NB. =========================================================

4!:55 <'boot'
18!:4 <'base' NB. end in base

Parse=: 3 : 0
        y. =. '+ ' charsub y.
        Unicode y.
)

Unicode=: 3 : 0
        in=. 1 2 +/~ i=. bx y.='%'
        try. s=. a. {~ 16 #. '0123456789ABCDEF' i. in { y.
                 y. =. s i } y.
                 y. =. y. #~ 0 in } 1 #~ #y.
        catch. y.
        end.
)

ErrorHandle =: 3 : 0
        try.
                stk =. dbstk ''
                if. 0 do.
echoJ ('Name';'Error Number';'Line Number';'Name Class';'Linear Representation';'Name of Script';'Arguments';'Locals Name-Value';'Suspension') , stk
                else.
'name error line class linrep filename arg nameval sus' =. {. stk {~ bx '*' = 8 pick"1 stk
                        echo '<CODE><BR><BR><font color=#AA0000><B>Error #' , 
(":error)
                        echo ' [' , (0 pick '|' cut 1 }. 0 pick ':' cut 13!:12 '') , 
'] </B>'
                        echo '<UL type="square">'
                        echo '<LI><B> File : </B> ' , filename
                        echo '<LI><B> Function : </B>' , name
                        echo '<LI><B> Line :</B> ' , (":line+1)
                        echo ' (' , }.((line+1) pick LF cut linrep) , ')'
                        nameval =. ,"1 (3 }."1 ;"1 (<' = ') , each ": each 
nameval)
                        echo '<B><BR>&nbsp;&nbsp;&nbsp;' ,"1 nameval ,"1 '</B>'
                        echo '</FONT></CODE>'
                end.
        catch.
        end.
        exit ''
)

PcPara=: 13 :'y. rplc ,|.(''%''&,&":each i.#x.),.":each x.'

exist =: 3 : 0
        -. _1 = 4!:0 < y.
)

ReadCon =: 3 : 0
 str =: y.
 GetStdHandle =. 'kernel32 GetStdHandle i i'&(15!:0)
 ConsoleHandle =. ".": 0 pick  GetStdHandle -10
 ReadFile =.'kernel32 ReadFile i i * i *i *'&(15!:0)
 a =. 0
 ConOut =: ''
 while. a < y. do.
        R=:ReadFile ConsoleHandle;(25000#' ');(25000);(,0);<<0    
        if. (>4{R) > 0 do.
                ConOut =: ConOut , (>4{R){.>2{R
                a =. a + >4{R
        end.
 end.
 ConOut
)

enctovar=: 3 : 0
        tmp =: cocreate''
        idxV =. bx 2 = ;# each head =. '=' cut each '&' cut ;{.y.
((<'__tmp'),~ each deb each ;&{. each idxV { head) =. (}: each ;&}. each idxV { head) -. each <'" '
        if. exist 'name__tmp' do.
                if. exist 'filename__tmp' do.
                        (name__tmp, '_filename__U') =: filename__tmp
                        (name__tmp, '__U') =: ;LF,~  each 2}.y.
                else.
                        (name__tmp, '__U') =: ;}.y.
                end.
        end.
        codestroy__tmp''
        erase 'tmp'
)

delta =: }. - }:
DiffPrev=: 3 : '0, (}:y.) ~: }.y.'
keyindex =: 3 : '(delta b, #y.) # b =. 0, bx DiffPrev y.'
keyindexall =: 3 : '(k #/. k) # i. #~.k =. keyindex y.'

3 : 0 ''
        9!:11 (20)

        NB.Debug Procedure
        
        load 'debug'
        load 'strings'
        load 'files'

        13!:15 'ErrorHandle '''''
        13!:0 ]1
        
        NB. Verb Definition
        echo =: 1!:2&4
echoJ =: 3 : 'echo ''</PRE>'',~''<PRE>'', LF, (;(<LF) ,~"1 LF cut"1 ": y.) rplc ''&'';''@'';''<'';''&lt;'';''>'';''&gt;'''
        exit =: 2!:55
        smoutput =: echo
  exist =: 0: <: 4!:0 @ <
                        
        NB. Environment Variable
        SERVER_SOFTWARE =:      2!:5 'SERVER_SOFTWARE'
        SERVER_NAME =:          2!:5 'SERVER_NAME'
        GATEWAY_INTERFACE =:    2!:5 'GATEWAY_INTERFACE'
        SERVER_PROTOCOL =:      2!:5 'GATEWAY_INTERFACE'
        SERVER_PORT =:          2!:5 'SERVER_PORT'
        SERVER_METHOD =:        2!:5 'SERVER_METHOD'
        PATH_INFO =:            2!:5 'PATH_INFO'
        PATH_TRANSLATED =:      2!:5 'PATH_TRANSLATED'
        SCRIPT_NAME =:          2!:5 'SCRIPT_NAME'
        QUERY_STRING =:         2!:5 'QUERY_STRING'
        REMOTE_HOST =:          2!:5 'REMOTE_HOST'
        REMOTE_ADDR =:          2!:5 'REMOTE_ADDR'
        AUTH_TYPE =:            2!:5 'AUTH_TYPE'
        REMOTE_USER =:          2!:5 'REMOTE_USER'
        REMOTE_IDENT =:         2!:5 'REMOTE_IDENT'
        CONTENT_TYPE =:         2!:5 'CONTENT_TYPE'
        CONTENT_LENGTH =:       2!:5 'CONTENT_LENGTH'
        
        if. (".": CONTENT_LENGTH) > 0 do.                                  
                POST_STRING =: ReadCon ".": CONTENT_LENGTH            
                if. 'UPDATER' -: 7{.POST_STRING do.
                        POST_DATA =: 7 }. POST_STRING
                        POST_STRING =: ''
                end.
        else.
                POST_STRING =: ''       
        end.

        NB. User variables locale
        U =: cocreate ''        

MainPath =: ApplicationPath =: tolower (1 + {: '\' ss PATH_TRANSLATED) {. PATH_TRANSLATED

        NB. Parse gets and post parameters and make them available in locale U
        
        GETPOST =. (POST_STRING, QUERY_STRING) rplc ';';(38{a.)
        
        VALIDATE =: 0
        
        if. #GETPOST do.
                if. LF e. GETPOST do.
                        Header =. {.cps =. }:LF cut GETPOST
                        kih =. keyindexall iH =. -. Header = (#;Header){. each 
cps
                        enctovar each (~.(bx iH){kih) { kih </. cps
                else.
                        PAR =. Parse &.> '=' cut every deb each (38{a.) cut 
GETPOST
                        if. (#PAR) do.
                                ((0 {"1 PAR) , each <'__U') =: (1 {"1 PAR)
                        end.
                end.
        end.

        load <PATH_TRANSLATED        
                
        coerase U
        
  exit ''
)

_________________________________________
FILE FINISH HERE
_________________________________________


6. Then, notepad index.ijs in your html root and put the following, in the file:

echo 'Content-type: text/html' , LF , LF

echo 'Hello World!'

echoJ 'abcd' ; < 3 4 $ i.10

7. Call http://localhost/index.ijs from your favorite browser and you'll see the following:

Hello World!
+----+-------+
|abcd|0 1 2 3|
|    |4 5 6 7|
|    |8 9 0 1|
+----+-------+

Most variables available from apache are in the boot.ijs script....All variables passed from GET or POST will be available in locale U. For example :

http://localhost/index.ijs?myvar=1234

You could have something like that inside index.ijs :

MyVerb =: 3 : 0
        echoJ 10 * ".myvar__U
)

There is a small debug feature that will display you an error inside your browser like PHP if you have a length error, syntax error, etc.. in your J code. However, please note that the Line Number shown is not valid. (not hard to fix but I always forget).

Have a nice day!

Simon
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to