Invoke Local System service through Web Client

Discussion in 'Java' started by Lalit, Sep 15, 2006.

  1. Lalit

    Lalit Guest

    Hi All,
    I have a requirement in my J2EE web application that the web client
    must be able to invoke local system service. Actually i want my web
    client to be able to print on a printer connected locally. I know the
    rule of web application is that it can not perform Files I/O with the
    local system because of the serious security issues.
    Can you suggest any way using applet or java web start or other than
    these. The motive is to write on file "lpt1".
     
    Lalit, Sep 15, 2006
    #1
    1. Advertising

  2. Lalit

    Oliver Wong Guest

    "Lalit" <> wrote in message
    news:...
    > Hi All,
    > I have a requirement in my J2EE web application that the web client
    > must be able to invoke local system service. Actually i want my web
    > client to be able to print on a printer connected locally. I know the
    > rule of web application is that it can not perform Files I/O with the
    > local system because of the serious security issues.
    > Can you suggest any way using applet or java web start or other than
    > these. The motive is to write on file "lpt1".
    >


    You could try using Java's printing API, though they are hard to work
    with (IMHO), and you might still face security restrictions.

    The other solution is to sign your web client, so that users may grant
    permission to local resources (including file IO).

    If you need more details, please specify whether your web client is an
    HTML embedded applet, a Java Web Start Applet, a Java Web Start Application,
    or something else.

    - Oliver
     
    Oliver Wong, Sep 15, 2006
    #2
    1. Advertising

  3. Lalit

    Lalit Guest

    Hi Oliver,
    Thanks for the reply.

    > If you need more details, please specify whether your web client is an
    > HTML embedded applet, a Java Web Start Applet, a Java Web Start Application,
    > or something else.


    My application currently using JSP and JS only. I can use applets or
    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.
    But that requirement is only to solve the purpose of printing data
    locally from my web page.
    Is it possible to add only one button of the applet on my JSP page?
     
    Lalit, Sep 18, 2006
    #3
  4. Lalit wrote:
    > (Oliver)
    > > If you need more details, please specify whether your web client is an
    > > HTML embedded applet, a Java Web Start Applet, a Java Web Start Application,
    > > or something else.

    >
    > My application currently using JSP and JS only. I can use applets or
    > 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.
     
    Andrew Thompson, Sep 18, 2006
    #4
  5. Lalit

    Lalit Guest


    > 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.
     
    Lalit, Sep 18, 2006
    #5
  6. Andrew Thompson wrote:
    >
    > 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)


    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
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
     
    Thomas Hawtin, Sep 18, 2006
    #6
  7. Thomas Hawtin wrote:
    > Andrew Thompson wrote:
    > >
    > > 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)

    >
    > 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.
     
    Andrew Thompson, Sep 18, 2006
    #7
  8. Lalit

    Lalit Guest

    Friends, any solution for my problem?
     
    Lalit, Sep 19, 2006
    #8
  9. Lalit wrote:
    > > 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?


    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.
     
    Andrew Thompson, Sep 19, 2006
    #9
  10. Lalit

    Lalit Guest

    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.
     
    Lalit, Sep 19, 2006
    #10
  11. Lalit wrote:
    > 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.


    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.
     
    Andrew Thompson, Sep 19, 2006
    #11
  12. Lalit

    Lalit Guest


    > 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.
     
    Lalit, Sep 19, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    908
    dgleeson422111
    Jan 26, 2010
  2. Bob

    How to invoke a web service through UDDI

    Bob, Dec 11, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    157
    Dan Rogers
    Dec 13, 2004
  3. Replies:
    0
    Views:
    213
  4. Zean Smith
    Replies:
    0
    Views:
    261
    Zean Smith
    Apr 25, 2006
  5. dgleeson422111

    consume local web service -ok consume remote service - Not OK

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    1,615
    dgleeson422111
    Jan 31, 2010
Loading...

Share This Page