• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Daniel Reznick
Ranch Hand
Posts: 50
Eclipse IDE Google App Engine jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, your best bet might be from the following:

http://www.webdeveloper.com/forum/archive/index.php/t-24272.html
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just write the PDF file to the response stream.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic