?
Solved

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

Posted on 2005-03-16
7
Medium Priority
?
198 Views
Last Modified: 2010-04-01
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
Comment
Question by:letsbedecent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13561865
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
 

Author Comment

by:letsbedecent
ID: 13561886
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
 
LVL 92

Accepted Solution

by:
objects earned 1500 total points
ID: 13561909
> 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:letsbedecent
ID: 13561959
i will have to test it....
0
 

Author Comment

by:letsbedecent
ID: 13600851
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
 
LVL 92

Expert Comment

by:objects
ID: 13608643
Perhaps because those formats are not supported.
0
 

Author Comment

by:letsbedecent
ID: 13610031
not supported by whom ??
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question