Security Restrictions on Printing

As a general rule applets are not allowed to initiate print jobs. Only applications can do that. You wouldn't want a malicious applet to churn your printer with many pages of pure black, wasting all your toner, for example.

The checkPrintJobAccess() method of the SecurityManager class is used to determine whether or not printing is allowed.

public void checkPrintJobAccess()

For example,

try {
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) sm.checkPrintJobAccess();
  // print...
}
catch (SecurityException ex) {
  System.err.println("Sorry. Printing is not allowed.");
}

Previous | Next | Top | Cafe au Lait

Copyright 1997 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified May 5, 1997