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

Proving Print window on the client PC using JApplets

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
hemanth146
Asked:
hemanth146
  • 5
  • 4
1 Solution
 
kawasCommented:
if you want to print an html page, use window.print() from within the html (javascript).
0
 
hemanth146Author Commented:
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
 
kawasCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
hemanth146Author Commented:
so if i sign it will i able to access client side printer resources?
0
 
kawasCommented:
yes
0
 
hemanth146Author Commented:
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
 
kawasCommented:
you will have to create a jar file first ... then sign it

creating a jar file: http://www.javacoffeebreak.com/faq/faq0028.html
0
 
kawasCommented:
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
 
hemanth146Author Commented:
well thanks for the help.will try the above things and get back to u if have any issues.
0
 
SamsonChungCommented:
Thanks Kawas Now my crazy mobile JPad will actually work!!! :) too bad I can't save the file directly to my remote server....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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