JHP: J Hypertext Processor
JHP is a J based engine to run server-side web applications and create dynamic web content. Syntax is similar to PHP or ASP. JHP can run on any platform and web server.
Browse
JHP at
olegykj.sourceforge.net to see it in action live on that server. The above link also contains documentation. (Note: those pages require that javascript be enabled in the browser.)
See also: examples in
examples folder in SVN; change
history.
Examples
The following source code is an example of JHP.
<% ContentType'text/html' %>
<html><head>
<link rel="stylesheet" type="text/css" href="style.css">
</head><body>
<h2>Random Test</h2>
<p>Time is <%= 6!:0 '' %></p>
<% 9!:1 >.{:6!:0 '' %>
<p>Random array with seed <%= 9!:0'' %></p>
<pre><%= ":3 4 ?@$ 100 %></pre>
</body></html>
Syntax
JHP syntax is similar to ASP or PHP. Plain HTML is entered as is. J code is introduced by matching pairs of percent brackets <% ... %>. As a result, plain text is sent to the server as is and the J code is executed.
Any output in a particular piece of code is sent in between the surrounding plain HTML. Two verbs are used for output: print and println, the latter adding a LF to the end. These verbs format arguments as string.
<%= ... %> is a short cut for <%print ... %>. The content between such brackes cannot contain new lines, whereas the regular brackets permit them, as in J script.
It is required that the first line of the page specifies the MIME format, such as
<% ContentType'text/html' %> <html><head> ...
It is possible to produce any format output, such as XML, CSV, images, audio, etc. However, you must pay attention to observe spaces or absence thereof between the percent brackets.
JHP Configuration steps for Microsoft IIS 7.0
Make sure the required/desired components of Internet Information Services are installed.
The currently installed components can be accessed via Start|Control Panel|Programs|Turn Windows features on or off
A fairly minimal installation might include the following components:
Web Management Tools
IIS Management Console
World Wide Web Services
Application Development Features
CGI
Common Http Features
Default Document
HTTP Errors
Static Content
Health and Diagnostics
HTTP Logging
Request Monitor
Performance Features
Static Content Compression
Security
Request Filtering
Create the web site
Start the IIS Management Console
Start|Control Panel|System and Maintenance|Administrative Tools|Internet Information Services (IIS) Manager
Right click on the Default Web Site and Add Virtual Directory
Alias: jhpex
Physical Path: d:\j60x\addons\web\jhp\examples
Click OK
Create a mapping between .jhp files and jconsole.exe
Click on virtual folder "jhpex" in leftmost pane.
Choose Handler mappings|Add Script Map...
Request path: *.jhp
Executable: "d:\j601\jconsole.exe" web/jhp/run %s %s OR "d:\j602\bin\jconsole.exe" web/jhp/run %s %s
Name: "J Hypertext processor".
Click OK
Answer Yes when prompted whether you want to "enable this ISAPI extension?".
Click on top level server in leftmost pane
Open the ISAPI and CGI Restrictions and check that and entry exists allowing jconsole.exe. Edit and add a description if desired.
Permissions
The User account used for Anonymous Authentication needs to have Read & Execute access to the folder
The same account also needs to have write access to the ~temp\jbreak directory. A better, more secure alternative is to change the setbreak verb in ~system/main/break.ijs as described in the Troubleshooting section of JHP's config.html (~addons\web\jhp\examples\config.html).
