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

how to print data from servlet to hp-printer

 
darshan karle
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,

I am trying to print data from servlet to hp printer.i am new to it.
i it possible for anybody to send sample code. pleaseeeeeeee.
or paste web site name where i can find the code

regards
darshan
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to send the job to a printer connected to the server or to the client's machine?
 
darshan karle
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.
my system is connected to LAN network.
i want to send data to the printer connected to client machine
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by darshan karle:
...
i want to send data to the printer connected to client machine


In that case, this is more of an HTML question than a servlet question.
I'll move this to our HTML/Javascript forum for you.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18020
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A servlet cannot print for a client for 3 reasons:

1. A servlet is built on HTTP, and HTTP can only respond to requests. If the browser makes a request, the response will go to the browser, so the browser would have to then route the output to a printer (more on this shortly). A printer doesn't make HTTP requests, so until someone invents one that can

2. The whole infrastructure of web client and web server is designed to sandbox out automated printing because believe it or not, people have using print subsystems to do rude, evil and abusive things.

3. The servlet doesn't know what the client's printing options are (what, if any printers are available and what drivers and print options to use).

A web client can print directly if it contains an applet that prints, but do to sandbox rules, this requires that the applet be digitally signed and that the client machine is set up to accept it. This is usually more trouble than it's worth.

More commonly, the applet simply generates an HTTP response that the user then prints using their browser's File/Print menu or a JavaScript function that does the same thing in software. The response is usually HTML, plain text or a PDF.
 
darshan karle
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply,

can you please send the sample code to send data from browser to HP printer.
or send me the link where i can find more information about this.
please i am new to this topic.

regards
darshan
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All you have to work with is window.print()

Eric
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually File --> Print works too Just have a style sheet that is media="print".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic