aspose file tools*
The moose likes JSF and the fly likes How to print a file that is uploaded using JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to print a file that is uploaded using JSF" Watch "How to print a file that is uploaded using JSF" New topic
Author

How to print a file that is uploaded using JSF

Richard Dennis
Greenhorn

Joined: Nov 05, 2012
Posts: 9
i have now managed to create an upload in jsf that allows the user to upload a txt file, i can also display what has been uploaded, what i need to know now is how can i print this text to a printer when a user presses a command button
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

Where is the printer located? Attached to the client machine, or on the server?

On the client side, you can return the page wrapped in HTML with a javascript "print" button on it. On the server side, it may be a bit more complex.

Note that in either case, it won't be completely automatic because the components in question are designed to resist security exploits made in print requests. Yes, there are such things. Plus, if all else fails and an app just wants to be petty, mean, and nasty, it could emit thousands of pages of garbage text to the printer, so the protection mechanisms do things like ensure that such things aren't run in the middle of the night when nobody's there to stop them.


Customer surveys are for companies who didn't pay proper attention to begin with.
Richard Dennis
Greenhorn

Joined: Nov 05, 2012
Posts: 9
Tim Holloway wrote:Where is the printer located? Attached to the client machine, or on the server?

On the client side, you can return the page wrapped in HTML with a javascript "print" button on it. On the server side, it may be a bit more complex.

Note that in either case, it won't be completely automatic because the components in question are designed to resist security exploits made in print requests. Yes, there are such things. Plus, if all else fails and an app just wants to be petty, mean, and nasty, it could emit thousands of pages of garbage text to the printer, so the protection mechanisms do things like ensure that such things aren't run in the middle of the night when nobody's there to stop them.



On the server side, it is a networked printer, i have the ip etc so was just hopping i would be able to send directly to it, and yes i understand it willn't be completly automatic, it don't need to be tbh
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

On the server side, printing is easier. Applets are sandboxed, so only signed applets can print. Server-side code printing to a printer attached locally or via LAN should be able to use the normal Java printing services.

The only real caveat is that since webapps should minimize processing time, you should offload anything that takes too long to get printed to an out-of-band process just like you would for things like long-running database operations.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to print a file that is uploaded using JSF
 
Similar Threads
uploading a file but want to restrict the type of files
renaming files after uploading
Jakarta FileUpload
File Download in Servlets
finding mimetype using javascript