Sub Class_Globals
Private js As Shell
Private mresp As ServletResponse
End Sub
Public Sub Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
mresp = resp
'save the request to a file
Dim out As OutputStream = File.OpenOutput(File.DirApp, "temp.txt", False)
File.Copy2(req.InputStream, out)
out.Close
Dim params As List
params.Initialize
'optionally set the printer
'params.Add("printername=novapdf")
params.Add("file=temp.txt")
js.Initialize("js", "printhtml.exe", params)
js.WorkingDirectory = File.DirApp
js.Run(-1)
StartMessageLoop '<--- wait for the event
End Sub
Sub js_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log("Success=" & Success & ", StdOut=" & StdOut & ", StdErr=" & StdErr)
If Success Then
mresp.Write("Message was printed successfully.")
Else
mresp.SendError(500, StdErr)
End If
StopMessageLoop '<-- close the secondary message loop
End Sub