Meaningless Drivel is fun!*
The moose likes JSF and the fly likes  How to launch a file at Client side? (Using java code)   Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark " How to launch a file at Client side? (Using java code)   " Watch " How to launch a file at Client side? (Using java code)   " New topic
Author

How to launch a file at Client side? (Using java code)

Daniel Reznick
Ranch Hand

Joined: Oct 23, 2008
Posts: 50

Hi, i got the following situation:

When user clicks on some link, I'm entering a java code of the ManagedBean processAction method in which I'm copying a file to a network drive, and than I want to open this file on the Client side, for example the file to be opened is a .pdf file.

I tried something but all I managed to do is to open the file on the server side, each time the user clicked on the link

p.s the important part is that the file is must be opened from the processAction method (java code)

Thanks ahead.
[ December 10, 2008: Message edited by: Daniel Reznick ]
David Win
Greenhorn

Joined: Dec 10, 2008
Posts: 3
I think the best way is to let the browser handle the download of the file. For example, if you click on a powerpoint file on the web, the browser automatically opens the file with the appropriate executable (MS Power point, open office or some other power point reader).

Depending on your application server, you can configure your HTTP server to let clients download files automatically (you don't actually need to write code to do this). The user simply clicks on the link and the file is automatically downloaded or opened for them and this action is handled by their browser.

But if you really want to try to run an executable, the most probably way that you can access files or executables from the client side is via Javascript or Java Applet code...and from the best of my knowledge, neither lets code execute any command (also anti-virus software will pick it up). You cannot leverage anything from JSP/JSF to do so because its all server side code.
David Win
Greenhorn

Joined: Dec 10, 2008
Posts: 3
Also, your best bet might be from the following:

http://www.webdeveloper.com/forum/archive/index.php/t-24272.html
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"David" welcome to Javaranch
please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Just write the PDF file to the response stream.
 
wood burning stoves
 
subject: How to launch a file at Client side? (Using java code)