You must use javascript on the client page.
window.print()
https://developer.mozilla.org/en-US/docs/Web/API/Window/print
If you want to try the applet approach give a look at this answer
You cannot do that for security reasons. If you could, applets would
already have become notorious for printing 10+ pages of 'special
offers' when you visit unscrupulous web sites.
OTOH, if the client is willing to accept one prompt at applet
start-up, you could digitally sign the code.
Also it should be possible to achieve a similar result using the PrintService from JNLP API without the need for a signed applet.
Like in the Following example
import javax.jnlp.*;
...
PrintService ps;
try {
ps = (PrintService)ServiceManager.lookup("javax.jnlp.PrintService");
} catch (UnavailableServiceException e) {
ps = null;
}
if (ps != null) {
try {
// get the default PageFormat
PageFormat pf = ps.getDefaultPage();
// ask the user to customize the PageFormat
PageFormat newPf = ps.showPageFormatDialog(pf);
// print the document with the PageFormat above
ps.print(new DocToPrint());
} catch (Exception e) {
e.printStackTrace();
}
}
// Code to construct the Printable Document
class DocToPrint implements Printable {
public int print(Graphics g, PageFormat pageformat, int PageIndex){
// code to generate what you want to print
}
}