This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing with servlets

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me how to print from a Servlet ?
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on where you want to print to. If you want to print to the screen, use PrintWriter and out.print. If you want to print to an error log, use System.out.print. Or are you talking about printing to a printer?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And is the printer connected to the server or the client? Most HTML/Browser applications which have a "print" button, just use it to produce an alternatively formatted version of the same data which will print sensibly.
 
vikinsa
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is no such way to get something printed by the servlet. But there is a good way in javascript. You can have the tested code from www.dynamicdrive.com This piece of code has a javascript function which can be called either from body onLoad or by any click event on the page. This is a good alternative to anything.
Try seraching <b>print</b> on www.dynamicdrive.com

------------------
Vikas Aggarwal
Technology Associate
(www.vikinsa.com)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic