dcsimg

How can I use a servlet to print a file on a printer attached to the client?

Serge Knystautas

The security in a browser is designed to restrict you from automating things like this. However, you can use JavaScript in the HTML your servlet returns to print a frame. The browser will still confirm the print job with the user, so you can't completely automate this. Also, you'll be printing whatever the browser is displaying (it will not reliably print plug-ins or applets), so normally you are restricted to HTML and images.

[The JavaScript source code for doing this is:
<input type="button" onClick="window.print(0)" value="Print This Page">
-Alex]