I'm trying to use the jZebra printing applet and am not sure how to use it from pages in different directories. The sample page has the following code:
<applet
id="qz"
name="QZ Print Plugin"
code="qz.PrintApplet.class"
width="55"
height="55">
<param name="jnlp_href" value="qz-print_jnlp.jnlp">
<param name="cache_option" value="plugin">
<param name="disable_logging" value="false">
</applet>
If the applet (qz-print.jar) and another file (qz-print_jnlp.jnlp) are in the same directory as the page with that code, then it works fine. However, I don't know what to change to get it to work if the web page is in a different directory. It seems like this is a trivial question, but I've been searching and haven't been able to find the answer.
How should I modify the above code to get the applet in the web page when it's in a different directory?
The tag you are using:
<param name="jnlp_href" value="qz-print_jnlp.jnlp">
Is the equivalent of this: (notice the "./"):
<param name="jnlp_href" value="./qz-print_jnlp.jnlp">
Java uses absolute or relative paths, just as an image tag would <img src="./foo.png />
So, if you've placed your applet in one folder called "dist" (ie http://mysite/dist/qz-print.jar
) but your page was located in another folder called "web"(ie http://mysite/web/mypage.html
) then you would have to change your relative applet tag to this:
<param name="jnlp_href" value="../dist/qz-print_jnlp.jnlp">
Or optimally, change the tag to be absolute path to the jnlp:
<param name="jnlp_href" value="/dist/qz-print_jnlp.jnlp">
Additionally, as qz finds better ways to load these tags, we put them in the sample.html. I would recommend you use the latest version from here .
At the time of writing this, the best way to use the tags is this way: <applet id="qz" archive="./qz-print.jar" name="QZ Print Plugin" code="qz.PrintApplet.class" width="55" height="55"> <param name="jnlp_href" value="qz-print_jnlp.jnlp"> <param name="cache_option" value="plugin"> <param name="disable_logging" value="false"> <param name="initial_focus" value="false"> <param name="separate_jvm" value="true"> </applet><br />
Note that the archive tag should be updated as well as the jnlp tag.
The three changes from the sample you are using to the sample I've provided above are:
archive=
tag for compatibility with certain versions of Safari. separate_jvm
tag is used to load a new instance of the Java Framework on page load, which seems to resolve some sporadic loading issues with Java 8. Finally, if you have clients that still run Java 6, I would advise you use deployQZ();
from sample.html instead, which does Java client version detection using Oracle's deployJava.js
script.
-Tres
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.