Link to home
Start Free TrialLog in
Avatar of letsbedecent
letsbedecent

asked on

How can an applet print on clients printer a document available on server ??

Hello all,

          I have an applet with code that uses javax.print API to lookup default printservices and print a particular document flavour ( in my case a GIF).  

         I compiled the applet class, signed it , and placed the resultant JAR file along with the jsp file that is using this applet to print(on clients printer).  

        This applet reades as input stream the GIF file that is to be printed. So, i put the GIF file also with the JSP file and the Applet signed Jar.

Now, My doubt is when this applet is loaded on to a browser (and suppose he trusts me) will this applet look for GIF file on client system or will it read the GIF file provided with the JSP on server ??

IF i want the applet to read the GIF available on server itself what should i do ??

How can i acheive printing on a client printer some document that is available on server ( say a text or a GIF file) ??
Avatar of Mick Barry
Mick Barry
Flag of Australia image

load the image using the URL of the image on the server.
you can either use the applets codebase to build this url or getClass().getResource(name)
Avatar of letsbedecent
letsbedecent

ASKER

if i use the applets codebase then in the jsp:plugin i have to specify the URL of the applet like
http://localhost:7001/testApplet   
and then in my applets code where i write a line like inputStream is = new BufferedInputStream(FileInputStream(xyz.gif)));  will this line search for the gif file at the above URL ???  

if i use getClass().getResource(name) where should i write this code....... i mean ... what is happening with this peice of code ??
getClass returns the applet class right.... and what does getResource do ??
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i will have to test it....
When i am using this API  i am able to print the GIF document but not the text document(.txt,.doc,.pdf), though i used AUTOSENSE and all other options of the DocFlavor. Can anyone explain why this is happening ??
Perhaps because those formats are not supported.
not supported by whom ??