> (Oliver)
> > If you need more details, please specify whether your web client is an
[quoted text clipped - 4 lines]
> any Java Web Start application if necessery (However i m not willing
> to), as i heard that web pages are not allowed to use local properties.
An applet in a web page, as well as a JWS application or
applet can do everything a normal application can do. So
long as..
- The code is signed.
- The user accepts the signed code (when asked by Java)
(Note that while an unsigned JWS application or applet *can*
print using the javax.jnlp.PrintService, it still requires the
end user's confirmation/permission - there are no 'free lunches'
when it comes to printing from a web-page - it requires the end
user's active involvement)
> But that requirement is only to solve the purpose of printing data
> locally from my web page.
The thing is, that is a big 'only'. If it were easy for a
'plain old web-page' to dump 300 page prints to a user's
printer without their active consent, that would be a huge
problem.
> Is it possible to add only one button of the applet on my JSP page?
Probably not in the way you are thinking of.
You might have an applet in a page that automatically
tries to send a print (it does not need any buttons),
but the code would have to be signed, and the user
would be asked if they want to let this applet have
'unrestricted access' (or words similar) to the user's PC.
Why not offer the document itself to the web-surfer?
Let them decide whether they want to print it.
Andrew T.
Lalit - 18 Sep 2006 12:27 GMT
> Why not offer the document itself to the web-surfer?
> Let them decide whether they want to print it.
Actually my application is Enetrprise i.e. J2EE and user may have to
print in bulk. User needs to print Barcodes on a Barcode Printer and
that can be 10 or 20 in one go. So can not bug the user 20 times.
However involvement for allowing the applet by user is no problem.
Can such a solution like........"On clicking a button on JSP, an applet
launches which takes data from JSP e.g. 20 Barcode numbers and prints
on the printer.." will work? If yes, can you tell me the implementation
of such an approach.
Andrew Thompson - 19 Sep 2006 09:27 GMT
> > Why not offer the document itself to the web-surfer?
> > Let them decide whether they want to print it.
[quoted text clipped - 7 lines]
> launches which takes data from JSP e.g. 20 Barcode numbers and prints
> on the printer.." will work?
Yes. Well, sort of..
After the applet is loaded (and assuming it is only ever
called when the user wants to print) it might automatically
initiate a print - but the user is asked to confirm it is OK.
So that is 'two clicks' from the time the user wants
to print the data, to when they see a print dialog.
For a print to take a 'couple of clicks' would be no
surprise to most users - so I don't see it as a
problem if the want the print.
But do the barcodes need any special formatting?
(Is it possible to present them on the web-page in such
a way that the user can simply print the web-page itself?)
Sorry - I am not that familiar with printing barcodes.
Assuming the barcodes *do* require special formatting,
then - yes, the applet can theoretically print them in one
go - send them all in the same print-job - after the end-user
has OK'd the print-job just once.
(BTW - are these barcodes in the JSP as text, or
images, or something else?)
>..If yes, can you tell me the implementation
> of such an approach.
No. I have never dealt with the print API, and am not
very familiar with bar-codes.
I sugggest you split this into two separate problems
1) Printing the barcodes.
2) Printing from an applet.
Note that you might experiment with printing (some generic
and simple document) from an applet, just to check the
way the security model works - assure yourself that the user
can 'OK' a print of one - or many - pages with a single click.
OTOH I would advise doing most of your work with the
printing API from an *application*. You might write your
class so it works as both.
Applications are much quicker and easier to develop and
debug, especially when the project requires access to
priviledged resources like the printer.
I hope that makes it a bit more clear (and that I have
not misunderstood what Thomas mentioned - that
was a surprise to me).
Andrew T.
Lalit - 19 Sep 2006 11:54 GMT
Hi Andrew,
> I sugggest you split this into two separate problems
> 1) Printing the barcodes.
> 2) Printing from an applet.
Printing thr Barcodes is not a problem. I can easily do it using a java
class i have already written. My main problem is Problem 2. I m
completely new to Applet world. I do not know how to write an applet
which can be invoked through JSP page and how to edit the prompt
message it will ask from the user while taking permissions to load.
Mainly experimentation with the following approach that you have
mentioned.
> Note that you might experiment with printing (some generic
> and simple document) from an applet, just to check the
> way the security model works - assure yourself that the user
> can 'OK' a print of one - or many - pages with a single click.
However, thanks a lot for the reply.
Andrew Thompson - 19 Sep 2006 13:40 GMT
> Hi Andrew,
>
[quoted text clipped - 7 lines]
> which can be invoked through JSP page and how to edit the prompt
> message it will ask from the user while taking permissions to load.
You can't. If you could, the message
"Would you like me to upload your bank account
details then wipe your system?"
..might be 'helpfully' edited by some nasty person, to..
"Want some chocolate?"
Andrew T.
Lalit - 19 Sep 2006 14:22 GMT
> You can't. If you could, the message
> "Would you like me to upload your bank account
> details then wipe your system?"
>
> ..might be 'helpfully' edited by some nasty person, to..
> "Want some chocolate?"
Ha ha ha..good one. Got your point that the message can not be changed.
I think i should do some hands on on the applet first.
Thomas Hawtin - 18 Sep 2006 14:30 GMT
> An applet in a web page, as well as a JWS application or
> applet can do everything a normal application can do. So
[quoted text clipped - 7 lines]
> when it comes to printing from a web-page - it requires the end
> user's active involvement)
The Java Plug-in does allow printing, but throws up a confirmation
dialog first.
It surprised me when I first saw it. Or at least when I saw the deadlock
from trying to print off the Event Dispatch Thread (might not be a
problem any more).
But, I've seen many web pages with JavaScript "Print" links that
actually do bring up a print dialog. (Most annoying, because what I
really want is for the page to be formatted on the screen reasonably.)
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Andrew Thompson - 18 Sep 2006 21:57 GMT
> > An applet in a web page, as well as a JWS application or
> > applet can do everything a normal application can do. So
[quoted text clipped - 10 lines]
> The Java Plug-in does allow printing, but throws up a confirmation
> dialog first.
You do mean an unsigned applet in a web-page, right?
> It surprised me when I first saw it.
It is news to me, as well. I would have expected a
SecurityAccessException (or similar), with no prompt.
Andrew T.
Lalit - 19 Sep 2006 08:19 GMT
Friends, any solution for my problem?