Solved

Proving Print window on the client PC using JApplets

Posted on 2006-11-14
13
172 Views
Last Modified: 2010-03-31
Hi,

I'm looking for a way to provide the client side with a Print window so that he/she can select the printer where the document can b printed.
So i've wriiten a JApplet code which pops-up the Java Print window and was able to print the document when invoked it on my local PC.

But when tried to call this applet from an HTML page that was deployed on the tomcat server, it was not showing any print window.
So can u tell me is this bcoz Applets r not given access to client side resources? If yes, is there any other alternative for providing this functionality?

Kindly reply me asap as this is urgent requirement.

Thanks.
0
Comment
Question by:hemanth146
  • 5
  • 4
13 Comments
 
LVL 13

Expert Comment

by:kawas
Comment Utility
if you want to print an html page, use window.print() from within the html (javascript).
0
 

Author Comment

by:hemanth146
Comment Utility
I dont wanna print an html page. But want to display a Print window on the client side using Applet showing his local printers so that I can configure and retrieve the printer settings.
0
 
LVL 13

Expert Comment

by:kawas
Comment Utility
if you want to use the applet, you will have to sign it:

//generate a key
keytool -genkey -keyalg rsa -alias your_alias_here
//save the certificate
keytool -export -alias your_alias_here -file your_certificate.crt
// sign the jar file
jarsigner your_applet.jar your_alias_here
0
 

Author Comment

by:hemanth146
Comment Utility
so if i sign it will i able to access client side printer resources?
0
 
LVL 13

Expert Comment

by:kawas
Comment Utility
yes
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:hemanth146
Comment Utility
so if my applet name class is 'PrintApplet.class" can u show me an eg of how to call this from a html page aftering signing it
0
 
LVL 13

Expert Comment

by:kawas
Comment Utility
you will have to create a jar file first ... then sign it

creating a jar file: http://www.javacoffeebreak.com/faq/faq0028.html
0
 
LVL 13

Accepted Solution

by:
kawas earned 500 total points
Comment Utility
Not sure how you embedded your applet in the html, but I had this once:

    <APPLET  CODE = "./my_applet.jar" WIDTH = "775" HEIGHT = "385" NAME = "applet" VSPACE = "10" HSPACE = "10">
            <PARAM NAME = CODE VALUE = "package.to.PrintApplet" >
            <PARAM NAME = CODEBASE VALUE = "." >
            <PARAM NAME = ARCHIVE VALUE = "./my_applet.jar" >
            <PARAM NAME = NAME VALUE = "applet" >
            <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
            <PARAM NAME="scriptable" VALUE="false">
      </APPLET>

then place the jar file and the html file at tomcat_home/webapps/your_web_app/
0
 

Author Comment

by:hemanth146
Comment Utility
well thanks for the help.will try the above things and get back to u if have any issues.
0
 
LVL 6

Expert Comment

by:SamsonChung
Comment Utility
Thanks Kawas Now my crazy mobile JPad will actually work!!! :) too bad I can't save the file directly to my remote server....
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now