• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

how to print data from servlet to hp-printer

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All you have to work with is window.print()

Eric
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually File --> Print works too Just have a style sheet that is media="print".
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic