Using XPath from a Java Applet
The Java XPath API described on the previous pages
is available from applets, at least with the Java plugin.
In practice, I've found that "out of the box", using XPath from a remotely-loaded
applet is unworkably slow (at least as of the Java 6 plugin update 13).
I've found a nasty workaround that appears to work, but which involves
signing the jar. The workaround is thus as follows:
- in your applet class's init() method (or before you first
use the XPath API), add
- sign the jar.
Setting this property explicitly prevents the XPath API from attempting to hit the network
in order to resolve it on every call to XPath.evaluate(), which appears to be the
cause of the horrifically slow performance of this call. Unfortunately, signing the jar
is then necessary in order to allow the system property to be set.
Unless otherwise stated, the Java programming articles and tutorials on this site are written by Neil Coffey.
Suggestions are always welcome if you wish to suggest topics for Java tutorials or programming articles,
or if you simply have a programming question that you would like to see answered on this site. Most topics
will be considered. But in particular, the site aims to provide tutorials and information on topics that
aren't well covered elsewhere, or on Java performance information that is poorly described or understood.
Suggestions may be made via the Javamex blog (see the site's front page for details).
Copyright © Javamex UK 2009. All rights reserved.