This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Local Printing from JSP  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1775
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I run the following Java class from a JSP so that it prints on the clients local printer? Note the arguments are returned from a servlet calling a Java class that connects to a remote data base. Also, this works when ran on local web app host but I need it to run when hosted from production web server.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future, please continue the discussion in the original topic rather than starting a new one.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. Any code running in a JSP or servlet executes on the server and has no access to the client system.

Any printing on the client can only be done by the print facilities built into the browser. (In other words, deliver a formatted page that the end user can print using the browser's File menu).

Probably not what you are after.

Sounds like you need either an applet or a fat client on the user end.
 
Steve Dyke
Ranch Hand
Posts: 1775
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can an applet accomplish this? If so where do I start?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An applet could run printing code, although as a security precaution it would need to be signed (or the local security policy relaxed). Of course, you'd be more likely to run into situations where no printer is available or none is properly configured, so error handling and recovery is important.
 
Steve Dyke
Ranch Hand
Posts: 1775
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give me more detail on how to get started with this approach?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Information about the security workarounds can be found at HowCanAnAppletReadFilesOnTheLocalFileSystem.

More basic information about how to create applets is in the applet FAQ, e.g. at http://faq.javaranch.com/java/AppletsFaq#basics
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!