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.
If you enjoy this Java programming article, please share with friends and colleagues. Follow the author on Twitter for the latest news and rants.
Editorial page content written by Neil Coffey. Copyright © Javamex UK 2021. All rights reserved.