Java Version Checker Applet
The
VersionCheck
applet checks for a specific Java major release &
if not available, redirects the user to another
page. The redirect page might be a page of your own, or
Sun's download page.
VersionCheck represents an alternative to Sun's
deployJava.js, or the older style HTMLconverter.
VersionCheck will work even if JavaScript is disabled.
The applet parameters are..
<param name='targetVersion' value='1.6'> The
version of the JRE required for applets on this page (or the applet page).
<param name='redirect' value='oldjava.html'> A page
to show if the required JRE is not installed.
<param name='applet' value='ourapplet.html'>
(Optional) An applet page to go to, if successful. Use this form
to avoid
having to embed the version checking applet directly in every applet
page that requires versioning.
<param name='bouncer' value='bouncer.html'>
(Optional) A page via which to direct offsite URLs. It is a good idea
to implement this if allowing the applet to be scripted based on the
URL query parameters.
This table summarises the effects of using VersionCheck
with or without an applet parameter.
|
Deployment aspect
|
No applet parameter
|
With applet parameter
|
|
Jumps to applet page
|
1
|
2
|
|
Applet page breaks 'back' button
|
false
|
true
|
|
Jumps to redirect page
|
2
|
2
|
|
Redirect page breaks 'back' button
|
true
|
true
|
Use this form for an applet that has the version checker embedded in the page.
Used this way, the client goes directly to the applet page
(the 'back button is not broken')
but is sent to the redirect page if insufficient Java
is available to run the main applet
(at which point, the 'back button is broken').
An example applet element for using the embedded form of the CheckVersion applet..
<APPLET
CODE='org.pscode.tool.applet.VersionCheck'
ARCHIVE='lib/vc.jar'
ALT='Enable Java to proceed'
WIDTH='200'
HEIGHT='30'>
<param name='targetVersion' value='1.6'>
<param name='redirect' value='http://www.java.com/'>
This applet requires the Java Plug-In available from
<a href='http://www.java.com/'>www.java.com</a>.
</APPLET>
Use this form to bounce the version checker to an applet in another page,
should the end user have the required java.
Used this way, the 'back button is broken' for both the applet
page and the redirect page.
Further, search engines are not going to
detect this type of link to an applet page, the page will be invisible
to them (unless there is also a direct HTML link). Of course, if the
only interesting thing on the page is the applet, search engines will not
document much besides the page meta tags and title in any case. Java binaries
are not 'search engine friendly'.
An example applet element for using the redirect form of the CheckVersion applet..
<APPLET
CODE='org.pscode.tool.applet.VersionCheck'
ARCHIVE='lib/vc.jar'
ALT='Enable Java to proceed'
WIDTH='200'
HEIGHT='30'>
<param name='targetVersion' value='1.6'>
<param name='redirect' value='oldjava.html'>
<param name='applet' value='applet.html'>
This applet requires the Java Plug-In available from
<a href='http://www.java.com/'>www.java.com</a>.
</APPLET>
- Version 1.0. 2008-07-12
-
Included functionality to parse the query parameters of the page URL
and use them to override (in most cases*) the applet parameters written in the page.
To do this we add a script dependency, using JavaScript to parse the URL parameters
and write the applet element. This might be done using a servlet, but we thought it
beneficial to show how to do it for a plain old web page.
E.G.
-
Added some very basic functionality to decode URL Encoded data.
This was directly to support URL parsing. Most of Java's
functionality to encode/decode URLs seems to have been introduced
in Java 1.2 - so we go for a simplistic, home rolled version.
-
Added a
bouncer attribute as a local page to show before
shifting a client browser 'off-site'. The page gets the destination
URL added as a query parameter. Since so much of the applet is now
configurable by URL, it opens the checker page to be used by 3rd
party sites. That is - the checker page is used coming from links
on the 3rd party site, and navigating back to the 3rd party site.
The bouncer attribute allows you to put another page
between the versioning applet, and returning to the final destination.
This leaves it up to you what to do with that final link (and
possibly the user's attention for a few moments).
* The bouncer attribute is one that cannot be overriden in the URL!
- Version 1.0-beta. 2008-07-05
SDN Share code -
applet entirely rewritten.
-
Class changed from the (default package)
JavaVersionApplet to
org.pscode.tool.applet.VersionCheck.
- Converted from using class availability to determine version,
to parsing it from the
java.version system property.
This represents
a fundamental improvement to the applet in that it no longer needs to
be recompiled for each new release.
-
Introduced dialog to provide user with messages, in case
this is a very small applet running in a browser with no status line.
-
URL construction simplified (within the code).
-
Introduced fail-safe dialog message on failure to
showDocument().
-
Introduced the
applet attribute to specify an applet web page
to redirect to if successful. This allows us to have one page (with dynamically
generated parameters) containing the version checking applet, to redirect to
any number of applet pages that require version checking.
-
Dropped all support for the
target attribute of the redirecting URLs.
Specifying targets has become more problematic and contentious over time.
- Version 0.2 works on Win2K for the browsers mentioned above.
Still untested in browsers on Mac, Linux, Unix, Solaris...
- Version 0.1 works for IE 5, Mozilla 1.3a, NN 6.2 on Win2K. It
fails for Opera 6.0, no redirect happens for JRE 1.5. As yet
untested in browsers on Mac, Linux, Unix, Solaris...
- The beta version had a faulty call to a method introduced
in the 1.2 JRE
- The
VersionCheck source code at
SDN Share.
- The pre-built archive of the
VersionCheck binary. This saves
having to obtain a 1.1
rt.jar for compiling.
- The current
source & build files. For those
brave enough to attempt compilation using a
-bootclasspath
for cross-compilation! The cross-compilation requires a Java 1.1
rt.jar to be successful, you can get one from the
Java 1.1.8
JRE or
SDK supplied by Sun.
|