Java Web Start Sample Application

Software Required

·  JDK 1.6 and run time java should be enabled with browser.

·  Policy Server.

·  Web Agent.

Details

Java Web Start provides a platform-independent, secure, and robust deployment technology. It enables developers to deploy full-featured applications to end-users by making the applications available on a standard web server. With any web browser, end-users can launch the applications and be confident they always have the most-recent version. Java Web Start features include the ability to automatically download and install a JRE in the case where the user does not have Java installed, and for programmers to specify which JRE version a given program needs in order to execute. The user does not have to remain connected to the Internet to execute the downloaded programs, because they execute from a locally-maintained cache.

Java Web Start application is the basically a java application that runs out of the context of the browser through JNLP (Java Network Launching Protocol) protocol. The JNLP protocol, defined with an XML schema, specifies how to launch Java Web Start applications. JNLP consists of a set of rules defining how exactly to implement the launching mechanism. JNLP files include information such as the location of the jar package file and the name of the main class for the application, in addition to any other parameters for the program. A properly configured browser passes JNLP files to a Java Runtime Environment (JRE) which in turn downloads the application onto the user's machine and starts executing it.

JNLP works in a similar fashion to how HTTP/HTML works for the web. For rendering a HTML webpage, after the user clicks on a weblink, the browser submits a URL to a webserver, which replies with an HTML file. The browser then requests the resources referred to by this file and finally renders the page once it has received enough information.

The sample Java web start application consists of “createJnlp.pl” and “TestJnlp.jar” file. “createJnlp.pl” file set the all the parameters and rules for JNLP protocol in the response. The “createJnlp.pl” file also set the URLs and session cookie in the JNLP arguments list so that these arguments will pass as an argument to the “TestJnlp.jar” at runtime. At runtime, requested “createJnlp.pl” internally set the JNLP protocol in response that launches the “testJnlp.jar” class on browser with the suitable arguments (URL and session cookie).

The “testJnlp.jar” jar consists of “jnlp.jar” and the main class “TestJnlp”. The “jnlp.jar” jar file is comes along with the JNLP Developers Pack. This jar file is also present in the sample jnlp directory of JDk1.6. The “TestJnlp” extends the java swing class “JFrame” to open the JFrame window. The “TestJnlp” class does the following functionality.

1.  The class gets the arguments from request and creates the JFrame container to display the response from requested URL and other messages.

2.  In this class the time listener has been used to generate action event after every 3 seconds. So that it request to the server page "time.pl" after every 3 seconds and get the response from the "time.pl" page.

3.  After getting the response it retrieves the necessary header (content-type) from response. And check that whether the response is web 2.0 responses or not by searching the SiteMinder attributes (SteiminderReason & SiteminderRedirectURL) in the response body.

4.  If the response body contains the Siteminder attributes then it works according to that attributes i.e. if the value of attributes "SiteminderReason" = "challenge" and "SiteminderRedirectURL" = "" then it redirect to the root URL else it redirect to the URL that is present in the "SiteminderRedirectURL" attribute.

5.  If the response body doesn't contain any SiteMinder attributes then this body is simply added into the JListBox.

6.  If there is any exception occur during processing, then it display error message pop-up.

Steps to run the application

1.  Install PS and WA. Configure WA with IIS web server.

2.  Protect only the launch-jnlp folder with form auth scheme.

3.  Set the path of “max.html” and “idle.html” html files in the MaxTimeOutURL and IdleTimeOutURL of ACO.

4.  Do the setup as per the test cases present in the web2.0 DDS. (Refer section 6).

5.  From browser request the “Home.html” page.

Note: make sure that you have changed url variable in launch-jnlp\createJnlp.pl to your web server URL

Flow Diagram

Sample Code

APPENDIX

In case while starting java application, it gives error related jar signing/security exception.

Then please build the TestJnlp.jar as per following instructions..

1.  Download the attached build-jnp.zipped

2.  Rename build-jnp.zipped to build-jnp.zip.

3.  Extact the contents.

4.  Open command prompt and change the directory to extracted contents.

5.  Rename build.txt to build.bat

6.  Run build.bat (I will create a TestJnlp.jar and copies it to C:\Inetpub\wwwroot\jnlp\)

Note:
1. Make sure that jarsigner is in machine’s path variable.

2. Make sure the Folder C:\Inetpub\wwwroot\jnlp exists.

Sample ACO Parameters (for IIS based application)

Parameter Name: WebAppClientResponse

Parameter Value: Resource=/launch-jnlp/time.pl|Method=GET|Status=200|Body=C:\Inetpub\wwwroot\custom_web20.xml|Content-Type=text/xml

Parameter Name: MaxTimeoutURL

Parameter Value: http://b2smdvw2k3s2-7.clearcase.com/home/max.html

Parameter Name: IdleTimeoutURL

Parameter Value: http://b2smdvw2k3s2-7.clearcase.com/home/idle.html

Parameter Name: OverlookSessionForUrls

Parameter Value: /launch-jnlp/time.pl

Sample Scripts