|
Client Deployment
JNetStart can start the following types of Swing clients:
- JFrame Clients - started by the JNetStart plugin installed in Internet Explorer or Firefox.
The plugin launches the applications in a separate JVM;
- JApplet Clients - these are regular applets that can be loaded by the Accendia Browser or the
JNetStart bootstrap applet.
Launching Applets in the Accendia Browser
The Accendia Browser can load HTML3.2 pages and regular Java Applets. To load a Java Applet
the user must type the applet address in the location field or click a link in an HTML page
containing the applet address. The applet address has the following format:
jns://server_name:port/application_name/applet_class_name?jnsparam1=value1&jnsparam2=value2&...
The port is optional and defaults to 443.
To launch the sample application SwingSet2 deployed with the installation package enter the applet address
in the location field:
jns://server_name/SwingSet2/SwingSet2Applet
The developer may also provide an HTML page with the applet link:
<a href="jns://server_name/SwingSet2/SwingSet2Applet">SwingSet2</a>
When the account name is not provided in the link the browser will use the account guest and the password password in order to login to the server. If the user must specify JNetStart parameters in order to start an applet, for example the login name and the password, then it is preferable to provide a form:
<form action="jns://server_name/SwingSet2/SwingSet2Applet">
<table>
<tr>
<td align="right"> <img src="SwingSet2.gif"> </td>
<td> <font color="#0070A8" face="Arial"> <b>
SwingSet2 Demo
</b> </td>
</tr>
<tr>
<td align="right">User:</td>
<td><input type="text" name="jnsuser" value="guest"></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="password" name="jnspassword" value="password"></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Ok">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
The following parameters are interpreted by the browser:
- jnsuser
- The account name used to login to the server.
- jnspassword
- The login password.
- jnssecure
- Specify
true to enable secure communication between the browser and the server.
Secure communication can only be established if a certificate is installed on the server.
HTML pages are loaded by typing the page address into the location field or
clicking links with the following syntax:
http://server_name:port/directory_path/page.html
The port is optional and defaults to 80. The directory path and the page name are also optional
and default to /jns.html. For example the address
http://server_name:port
defaults to
http://server_name:port/jns.html
If a web page contains an applet link with the server name "hostname" the browser will translate the address into the server name from where the HTML page was loaded. For example if the user clicks the link
jns://hostname/WebSwingSet2/SwingSet2
in the page
http://accendia.com/jns.html
the address will be translated to
jns://accendia.com/WebSwingSet2/SwingSet2
This feature makes the HTML pages containing applet links server independent. Without the hostname translation the developer would have to adapt the HTML page for each server where the client is deployed.
Launching JFrame Applications
To launch a JFrame application the developer must create a web page containing the link to the
application. The launching is executed by the JNetStart plugin that is installed automatically
on the browser when the page is loaded.
To create a link to the SwingSet2 application deployed on the local server add
the following object in the <body> section of the HTML page containing the application link:
<OBJECT id="swingset2"
CLASSID="clsid:cf391f4a-65bb-48cb-b7fd-be169fa7811e"
CODEBASE="http://accendia.com/jns/jnetstart2.2.cab">
<param name="jvmver" value="1.6"/>
<param name="hostname" value="localhost"/>
<param name="port" value="443" />
<param name="secure" value="false" />
<param name="application" value="SwingSet2"/>
<param name="user" value="guest"/>
<param name="password" value="password"/>
<param name="classname" value="SwingSet2"/>
<param name="arguments" value=""/>
<EMBED pluginspage="http://accendia.com/jns/jnetstart2.2.xpi"
width="0" height="0"
type="application/x-jnetstart;jns-version=2.2.0.1"
jvmver="1.6"
hostname="localhost"
port="443"
secure="false"
application="SwingSet2"
user="guest"
password="password"
classname="SwingSet2"
arguments="" >
<NOEMBED>
<strong>
The JNetstart Plug-in is not installed on this browser.
<br />
<a href="http://www.accendia.com/jns/product.html">
Click</a> here for more information.
</strong>
</NOEMBED>
</EMBED>
</OBJECT>
The <OBJECT> tag works for Internet Explorer and is ignored by Firefox.
The <EMBED> tag works in Firefox and is ignored by Internet Explorer.
Somewhere in the HTML page add the visual link to the remote application:
<span onclick="start('swingset2');">
<img src="SwingSet2.gif"/>
<span >
On the script section of the page add the launching code:
<script type="text/javascript">
function start( id )
{
var embed = document.embeds[idx];
if( embed )
{
/* the browser is Firefox */
/* call the start() method exported by the JNetStart object */
embed.start();
}
else
{
/* the browser is IE */
var elem = document.getElementById( id );
if( elem )
/* call the start() method exported by the JNetStart object */
elem.start();
else
window.alert( 'Browser not supported.' );
}
}
</script>
The <object> or <embed> tags download and install the JNetStart plugin and instantiate
an application link object. The following plugin parameters must be provided:
- jvmver
- The minimum JVM version that is required in order to launch the application. If Java
is not installed on the client computer or a version older than specified by
jvmver
is installed then the application is not launched and an error message is displayed;
- hostname
- The hostname where the application is deployed;
- port
- The JNetStart server port;
- secure
- Set to
true if application classes and resources must be downloaded over
a secure connection otherwise set to false. A certificate must be installed
on the server side in order to use secure communication;
- application
- The name of the application deployed on the server;
- user
- The account name that is used to login to the server;
- password
- The login password;
- classname
- Fully qualified name of the application main class;
- arguments
- The application arguments must be provided in the same way as they would be provided
on the command line.
In addition to the start() method the JNetStart plugin object exports the method
launch() that allows the client to provide the launch parameters programatically.
Use this method when the user and password parameters must
be provided by the user in HTML forms:
<script type="text/javascript">
function launch( id, jvmver, hostname, port, secure, application,
user, password, classname, arguments )
{
var embed = document.embeds[idx];
if( embed )
{
/* the browser is Firefox */
/* call the launch(...) method exported by the JNetStart object */
embed.launch( jvmver,
hostname, port, secure, application,
user, password, classname, arguments );
}
else
{
/* the browser is IE */
var elem = document.getElementById( id );
if( elem )
/* call the launch(...) method exported by the JNetStart object */
elem.launch( jvmver,
hostname, port, secure, application,
user, password, classname, arguments );
else
window.alert( 'Browser not supported.' );
}
}
</script>
Launching Applets in a Web Browser
Applets are deployed on the server the same way as frame applications. The difference is that the
application applet is launched by the JNetStart bootstrap applet. The same as for frame applications
the classes deployed on the server will be downloaded on the client when first accessed rather
than downloading the application jars.
The following code adds the JNetStart bootstrap applet to the HTML page and links to the
SwingSet2 applet:
<OBJECT
CLASSID="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
CODEBASE="http://java.sun.com/javase/downloads/index.jsp"
height="100%" width="100%" >
<param name="type" value="application/x-java-applet;version=1.6">
<param name="code" value="com.accendia.netstart.client.applet.JNSApplet"/>
<param name="archive" value="netstart_applet2.2s.jar"/>
<param name="cache_archive" value="netstart_applet2.2s.jar"/>
<param name="cache_version" value="2.2.0.1"/>
<param name="jnshostname" value="localhost"/>
<param name="jnsport" value="443" />
<param name="jnssecure" value="false" />
<param name="jnsapplication" value="SwingSet2"/>
<param name="jnsuser" value="quest"/>
<param name="jnspassword" value="password"/>
<param name="jnsclassname" value="SwingSet2Applet"/>
<EMBED pluginspage="http://java.sun.com/javase/downloads/index.jsp"
type="application/x-java-applet;version=1.6"
code="com.accendia.netstart.client.applet.JNSApplet"
archive="netstart_applet2.2s.jar"
cache_archive="netstart_applet2.2s.jar"
cache_version="2.2.0.1"
height="100%" width="100%"
jnshostname="localhost"
jnsport="443"
jnssecure="false"
jnsapplication="SwingSet2"
jnsuser="guest"
jnspassword="password"
jnsclassname="SwingSet2Applet">
<NOEMBED>
<strong>
The Java Plug-in is not installed on this browser.
<br />
<a href="http://www.java.com">
Click</a> here to get the latest Java Plug-in.
</strong>
</NOEMBED>
<EMBED>
</OBJECT>
The JNetStart parameter names are prefixed with jns in order to distinguish
them from Java pluging parameters.
The JNetStart bootstrap applet supports the same mandatory parameters as the JNetStart plugin except jvmver
and arguments. The JVM version is enforced by the Java plugin. Application applet parameters must
be provided as standard applet parameters.
|