• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

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) ??
0
letsbedecent
Asked:
letsbedecent
  • 4
  • 3
1 Solution
 
objectsCommented:
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)
0
 
letsbedecentAuthor Commented:
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 ??
0
 
objectsCommented:
> 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 ???

no that'll look on the local box

if you want a stream use something like:

InputStream is = new BufferedInputStream(getClass().getResourceAsStream("xyz.gif"));

That will look in the same directory as the class file (that the call is made from) is stored on the server
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
letsbedecentAuthor Commented:
i will have to test it....
0
 
letsbedecentAuthor Commented:
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 ??
0
 
objectsCommented:
Perhaps because those formats are not supported.
0
 
letsbedecentAuthor Commented:
not supported by whom ??
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now