MOCHA Telnet for JAVA


Version 3.0


1.0 Product overview

Mocha Telnet is a telnet emulator written in java, which makes it possible from a java enabled browser, to connect a UNIX server.

1.1 Functionality

1.2 Clipboard

Use the mouse to select an area, or 2 x click a word on the screen. Use ALT+C to copy, ALT+V to paste. ALT+A to select all.

1.3 Connect

It is possible to connect to a host from the File menu. A pop-up window is shown. Enter a host name and a port number . The port number for telnet is default 23, and SSH 22.

Another solution is to give the ip and port address in the HTML file loading the telnet applet.

1.4 Function keys

Function keys can be used from the keyboard, or the toolbar

1.5 Focus

If keyboard focus, the cursor will be shown. On some browsers, focus must be clicked after a dialog box, such as the connect dialog has been closed.

1.6 Scroll bar

Can be selected from the menu. It is enabled as default, and allows the user to scroll 400 lines back. This will only work with simple applications, not if using a screen editor on the UNIX server.

1.7 Known problems with Applets

2.0 Parameters

Parameters to Mocha Telnet is given in the HTML file loading the java application. Nothing is stored on the users workstation.

2.1 HTML page

An applet is defined in a HTML page with label <APPLET>. See other source of information for how to write HTML. An example of a HTML page:
        <TITLE> Mocha Telnet example </TITLE>
        <APPLET CODE="telnet.class" ARCHIVE="telnet.jar"
        WIDTH="800" HEIGHT="500" scriptable="true">
        <param name="host" value="unix">
        <param name="port" value="23">
        <param name="ssh3" value="false">
        <param name="autoconnect" value="true">
        <param name="script1" value="ogin=joe">
        <param name="script2" value="ssword=12345678">
        <param name="user_ssh" value="joe">
        <param name="password_ssh" value="1234">
        <param name="license" value="jan">
        <param name="license_key" value="">
        <param name="font" value="Courier">
        <param name="keylayout" value="default">
        <param name="fontstyle" value="Plain">
        <param name="termtype" value="vt220">
        <param name="margin" value="36">
        <param name="response" value="MOCHASOFT TELNET">
        <param name="tool_bar" value="true">
        <param name="menu_bar" value="true">
        <param name="show_fxx" value="true">
        <param name="negotiate" value="false">
        <param name="debug" value="false">
        <param name="local_echo" value="false">
        <param name="scroll_wheel" value="true">
        <param name="scroll_bar" value="false">
        <param name="color_bg" value="#D3D3D3">
        <param name="color_fg" value="#1010FF">
        <param name="color_bold" value="#FF0000">
        <param name="color_cursor" value="#FFFFFF">
        <param name="new_line" value="false">
        <param name="keepalive" value="true">
CODE parameter must always be "telnet.class". It is the name of the master file for the binary Mocha Telnet product. To use the full width use "100%"

Each parameter is build of a name and a value. In the example above parameter host is given value unix. It is very important to remember <> around each line, and the value must be surrounded with "".

As to give keyboard focus to the applet when loaded add a small script:

            <script type="text/javascript">
            onload = function()
            document.getElementsByTagName( "APPLET" )[0].focus();

2.2 Parameter keylayout

It is possible to define values for all Function keys (F1-F20) in a customized file. If "default" is used, a default file included in the jar file will be used.

If a filename as "keys" is given, this file must exist in the same folder on the Web server, as the telnet.jar file.


  name=keylayout value="<a file name>"

2.3 Parameter license

Name of the company using Mocha Telnet. Should only be included together with parameter "license_key".


  name=license value="<name of a company>"

2.4 Parameter license_key

When ordering Mocha Telnet, an encrypted license code will be received. Use this together with parameter "license" to remove the time limit for a session. The license key for the Java version start with "E". A license key for another MochaSoft product cannot be used.


  name=license_key value="<encrypted key>"

2.5 Parameter script1 and script2

Use these two script options to perform auto login (telnet only), when the applet is loaded. Of course it can not be recommended to include a secret login and password in a HTML page, as everyone can read the source from a browser.

  name=script1 value="<text to find>=<text to answer with>
  name=script2 value="<text to find>=<text to answer with>

  name=script1 value="Login=guest"
  name=script2 value="Password=funny"

2.6 Parameter user_ssh and password_ssh

Use these two options to perform auto login (ssh only), when the applet is loaded. Of course it can not be recommended to include a secret login and password in a HTML page, as everyone can read the source from a browser.

  name=user_ssh value=<userid>
  name=password_ssh value=<password>

  name=user_ssh value="joe"
  name=password_ssh value="password"

2.7 Parameter negotiate

When a telnet session is created to a host, a negotiation takes place, where the setup of endpoints is agreed on. If this parameter is used, the negotiation will be displayed.


  name=negotiate value="true | false"

 Default is false.

2.8 Parameter local_echo

It is possible to let all characters typed on the keyboard be displayed on the screen as default. Normally this is not a good idea. It the host wants to run in this mode, it can ask Mocha Telnet direct. Most hosts will overwrite this parameter in the startup negotiation.


  name=local_echo value="true | false"

 Default is false.

2.9 Parameter new_line

The new_line parameter defines if <RETURN> key should send <cr> <lf> or just <cr>.


  name=new_line value="true | false"

 Default is false, which means only <cr>.

2.10 Parameter tool_bar

Defines if the toolbar below the menu bar should be shown.


  name=tool_bar value="true | false"

 Default is true.

2.11 Parameter scroll_bar

Defines if a scroll bar should be displayed.


  name=scroll_bar value="true | false"

 Default is true.

2.12 Parameter show_fxx

Defines if the f1 - f20 keys should be in the tool bar.


  name=show_fxx value="true | false"

 Default is true.

2.13 Parameter color_bg

The color of the background can be defined with this parameter.


  name=color_bg value="#rrggbb"


The syntax is the same as used in the HTML language.


  name=color_bg value="#20f030"

2.14 Parameter color_fg

The color of the foreground (characters) can be defined with this parameter.


  name=color_fg value="#rrggbb"


The syntax is the same as used in the HTML language.

2.15 Parameter color_bold

The color of the bold text can be defined with this parameter.


  name=color_bold value="#rrggbb"


The syntax is the same as used in the HTML language.

2.16 Parameter color_cursor

The color of the cursor can be defined with this parameter.


  name=color_cursor value="#rrggbb"


The syntax is the same as used in the HTML language.

2.17 Parameters host and port

These parameters defines which host to connect, when the applet is loaded. The default port number for telnet is 23 na SSH 22.

  name=host value=<a host name>
  name=port value=<number>

The host name can either be a name or an internet address as There is not a real server at this address!

2.18 Parameter SSH

Mocha Telnet can use protocols Telnet or SSH. Notice, certificates are not supported, only normal sign on with a user id/password.


  name=SSH value="true | false"

Default is false

2.19 Parameter autoconnect

Mocha Telnet can make a connection when the applet has been loaded.


  name=autoconnect value="true | false"

 Default is false

2.20 Parameter termtype

Mocha Telnet can on request from host inform about the type of terminal it emulates. (In unix it is the environment variable TERM)


  name=termtype value=<type of terminal emulation>

 Default is vt220

2.21 Parameter response

Select a user defined response ID text for the VT220 terminal. It is send to the host on a ENQ request.


  name=response value="ID text"


2.22 Parameter font and font style

Possible to define the display font


  name=font value="font name"
  name=fontstyle value="style"

Default is Courier. To see the font names possible to use, start mocha telnet in a browser, and select menu - settings - font.

Possible font styles are :Plain,Bold, Italic and Bold Italic.

2.23 Parameter keepalive

Telnet can in a telnet session send keep alive frames at 10 second intervals.


  name=keepalive= value="true | false"

 Default is true.

2.24 Parameter margin

Margin to be used around a screen print


  name=margin value="36"

 Default is 36

2.24 Parameter scroll_wheel

If enabled, the scrollbar can be moved with the mouse scroll wheel


  name=scroll_wheel value="true | false"

 Default is true

3.0 Keyboard mapping

As it is individual how to map the keyboard, all function keys has been made changeable. If parameter "keylayout" is not used or defined as default, a standard keyboard mapping file from the telnet.jar file will be used. See 3.1

The package includes an example keyboard file keys, which can be used with parameter "keylayout".

  name=keylayout value="keys"

Syntax for file "keys":

Following keys can be defined:

Example of a "keys" file:

            # VT220 keymap file
            # \033 = ESC
            UP   \033[A
            DOWN \033[B
            RIGHT \033[C
            LEFT \033[D
            f1   \033[11~
            f2   \033[12~
            f3   \033[13~  # a comment
remark none ASCII characters are written in octal as \xxx , where xxx is the octal value.

The comments (#) at end of the lines are not used by Mocha Telnet.

3.1 Default keyboard

The default file "keys", contains following mapping of the keyboard:

        Key           mapping        Key                mapping
        -----------------------      ----------------------------
        f1              f1           crtl f1              f1
        f2              f2           ctrl f2              f2
        f3              f3           ctrl f3              f3
        f4              f4           ctrl f4              f4
        f5              f5           ctrl f5              f5
        f6              f6           ctrl f6              f6
        f7              f7           ctrl f7              f7
        f8              f8           ctrl f8              f8
        f9              f9           ctrl f9              f9
        f10             f10          ctrl f10             f10
        f11             f11          ctrl f11              -
        f12             f12          ctrl f12              -
        Key           mapping        Key                mapping
        -----------------------      ----------------------------
        shift f1        f11          crtl shift f1        f11
        shift f2        f12          ctrl shift f2        f12
        shift f3        f13          ctrl shift f3        f13
        shift f4        f14          ctrl shift f4        f14
        shift f5        f15          ctrl shift f5        f15
        shift f6        f16          ctrl shift f6        f16
        shift f7        f17          ctrl shift f7        f17
        shift f8        f18          ctrl shift f8        f18
        shift f9        f19          ctrl shift f9        f19
        shift f10       f20          ctrl shift f10       f20
        shift f11        -           ctrl shift f11        -
        shift f12        -           ctrl shift f12        -

Part of the auxiliary keypad can be used as:

3.3 Transmitted Codes

When the default "keys" file is used the keyboard will transmit following codes:

Editing Keys:

        key     codes
        HOME            CSI 1 ~
        END             CSI 2 ~
        PGUP            CSI 5 ~
        PGDN            CSI 6 ~
        BACKSPACE       \010    # some UNIX servers uses \177
Cursor Control Keys:
        key     normal   application     vt52
        UP      CSI A    SS3 A           ESC A
        DOWN    CSI B    SS3 B           ESC B
        RIGHT   CSI C    SS3 C           ESC C
        LEFT    CSI D    SS3 D           ESC D

Function Keys

        key             codes
        F1              \033OP
        F2              \033OQ
        F3              \033OR
        F4              \033OS
        F5              \033[15~
        F6              \033[17~
        F7              \033[18~
        F8              \033[19~
        F9              \033[20~
        F10             \033[21~
        F11             \033[23~
        F12             \033[24~
        F13             \033[25~
        F14             \033[26~
        F15             \033[28~
        F16             \033[29~
        F17             \033[31~
        F18             \033[32~
        F19             \033[33~
        F20             \033[34~

SS3 = \217
CSI = \233 (or ESC [)


4.0 License System

The license system for Mocha Telnet is very user friendly. The encrypted parameter "license_key", together with parameter "license" gives a check for legal use. It is not possible to change the company name in "license", without ordering a new key from MochaSoft.

If parameter "license_key" is not given, the program will run in Demo mode, and a session is restricted to 180 seconds