This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes How to print Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "How to print" Watch "How to print" New topic

How to print

Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
How to print on the server side or on the client side using java servlets .Is it possible to print either client or server side using servlets
Jabez Justin

Joined: Jan 21, 2003
Posts: 1
Yeah ....It is possible to print in servlets.......try using PrintWriter class.
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
To print at clientside(using printer and not on console) u have to use window.print() method of javascript. You can not invoke client's printer using servlet.
[ January 21, 2003: Message edited by: Prakash Dwivedi ]

Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
Marty Hall
Ranch Hand

Joined: Jan 02, 2003
Posts: 111
Is it possible to print either client or server side using servlets

Well, of course "servlets" cannot do anything on the client, since they do not run on the client. But, of course servlets can output (or refer to) normal Web content like HTML, JavaScript, or VBScript. The fact that JavaScript is generated by a servlet (or referred to by an HTML page that is generated by a servlet) does not change in the slightest what it can do on the client. The client does not know the difference.
Sure, a servlet could print on the server. But I can't see what good that would do anyone. Presumably the client has no access to the server machine.
- Marty

Java training and consulting
Bruce Jin
Ranch Hand

Joined: Sep 20, 2001
Posts: 671
To print on the client side, the user needs to use the mouse click.
Servlet can generate all kinds of printable files (pdf, html, Word, image etc.) and send to the user.
Maybe it is possible to have servlet send output directly to a printer instead of a browser.
Just a thought.

We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design

Crazy Bikes created by m-Power
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
Thanks for everybody given valuable information
I agree. Here's the link:
subject: How to print
It's not a secret anymore!