Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 776
  • Last Modified:

Open word/excell file in client.

Hi everyone, i'm trying something that i don't know if it's possible:

I've got a tomcat server in a linux system and i'm trying to open a file in the client machine.

The idea is, he clicks a button and, say and excell file or word file opens up. (or whatever file opens whatever program that it's extension is associated with in the client machine).

is this possible? what code should i use.? jsp or javascript is fine by me.
0
ogog
Asked:
ogog
  • 2
  • 2
1 Solution
 
jrm213jrm213Commented:
You should just need to navigate the browser to the file and the mime types should take over from there.

browsing to a .doc file should open in Microsoft Word, if the user has the appropriate application installed, and that application is set to be the default to open that type of document.

This is the behavior of the browser and the operation system.

so you could navigate to it through javascript or just use an anchor tag that points to the document. The browser should open the document in the correct application.


you can force or try to force a browser to open in a particular application by changing the mime-type of your webpage. So if you had a webpage called test.asp you could make it open with Excel if the user has Excel installed by doing the following at the very beginning of the page even before the html tag

<%@ Language=VBScript %>
<%
   'Change HTML header to specify Excel's MIME content type
   Response.Buffer = TRUE
   Response.ContentType = "application/vnd.ms-excel"
%>
0
 
jrm213jrm213Commented:
Note, if you are trying to open a file that exists on the local users hard disk somewhere, you will need to know the path of the file on the disk and instead of http://yoursite.com/blah.doc as the href you would use
the acutal path to the document ie... c:\documents and settings\usename\desktop\blah.doc

0
 
ogogAuthor Commented:
i'll try that and report back points in about 3 days.

thank you very much!
0
 
b0lsc0ttCommented:
Why did you accept that comment as the answer?  Did you try it?  Did it work for you?  Where was this page located (i.e. Internet site, intranet, local machine)?

That comment will not work in an Internet page.  The browser doesn't allow access to local file even if you know the path.  There are a few exceptions in non-Internet uses but they are browser specific and rare.  Please reply to let us know that you didn't just accept a comment.  In most cases that "answer" is wrong.

bol
0
 
ogogAuthor Commented:
i don't have pleasure in accepting wrong answers, obviously it did work. the file is local.

the answer was simple and effective to what i looked for, otherwise i would have not reated it Ecellent.

i forgot to accept it sooner because it worked! if it didn't i would have post a comment faster.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now