Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

send data from servlet to printer

 
Ray Kumar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to send output data directly to printer at the client from servlet
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can't be done directly (think about it -- how is the Servlet supposed to know about your printer?). The easiest thing is to put Javascript attached to your resulting HTML page that sends the page to the printer once it arrives at the browser... See this sample for how to do this in IE.
Kyle
 
Ray Kumar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.
In my case the response receiver is not browser, but a rich client(java application), uses http tunneling to servlet to get the data. servlet generates pdf stream or file at the server side, it is got to be printed at the client side.

any ideas will be appreciated.

Thanks !
 
Ken Boyd
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never did it myself but javax.print.* might be of help.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup. It won't be the Servlet's responsibility at all then; it's your rich client code's responsibility to print it. Look into javax.print as Nehul suggests.
Kyle
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"PK"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
 
Ralf Rottmann
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want the server side to initiate printing? Is there any specific reason that prevents you from doing it client side?
 
Ray Kumar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, I tried to create the pdf files at the client side, but generating pdf files (FOP) is really taking too much memory, so I swiched to server side. Our clients do not have enough RAM.

BTW, Any ideas on better PDF generator API's (free) especially with memory ?.
Thanks !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic