What is Ajaxterm4j?
Ajaxterm4j is a Java port of Ajaxterm, which lets us emulate a terminal on a web browser.
XmlHttpRequest that sends keystrokes and screens back and forth,
and a Java library that launches/manages processes. The library plays a similar role to xterm, except that whereas xterm is
implemented in C and use X for rendering, ajaxterm4j is implemented in Java and uses Ajax/HTML for rendering.
<link rel="stylesheet" type="text/css" href="ajaxterm.css"/>
Ajaxterm4j creates a terminal inside a DIV element with the 'ajaxterm' as the CSS class name:
<div id="myTestTerminal" class="ajaxterm"></div>
Finally, instantiate a terminal. The first parameter is the ID or the element of the DIV element. The second argument is an option hash:
Glueing together the server-side is up to you. Depending on the web framework of your choice, how you intergrate this with your webapp will be different. Basically,
- For each terminal session, a
Sessioninstance needs to be created. (multiple clients can connect to the same
Sessioninstance to create screencast-like effect.)
- The URL specified in the
endpointparameter needs to call into
Refer to the javadoc of the
Session class for more details.
The source tree contains a demo application that you can run with
mvn install; cd webapp; mvn jetty:run
This project comes with a module that uses
trilead-ssh library to act as a SSH client and terminal.
In this model, browser and the webapp acts as a terminal and a pure-Java SSH client, and it speaks
the SSH protocol with a remote SSH server.
See demo application for the details.