aspose file tools*
The moose likes Servlets and the fly likes how to open a document in word application using servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to open a document in word application using servlet " Watch "how to open a document in word application using servlet " New topic
Author

how to open a document in word application using servlet

khurram mirza
Greenhorn

Joined: Jun 10, 2001
Posts: 25
how can we open an existing named file (e.g abc.doc) in word application,not in browser,using servlet.when i try to do this i get security related message.because when we open word application in normal way then it is Winword.exe file that run,not Winword.doc file.on the other hand i'm trying to open abc.doc file in its application program,remeber not in browser.
thanks in advance.
khurram mirza.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Check out the "content-disposition" header - it may (under Internet Explorer, at least) have an option to do what you want.


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

Joined: Jun 10, 2001
Posts: 25
is the "content-disposition" a part of request or response header.where can i check this header?
khurram mirza.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

It's a response header. Use like this:

The "inline" option means to open within the browser. In IE, you can edit the document - the browser simply becomes the Word parent frame, but it doesn't set up the familiar menu and toolbar stucture as it would if Word had launched externally.
For more info on the Content-Dispostion header, I recommend you search the Web using Google or whatever engine you are most comfortable with.
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
Tim, did you mean PDF file through your snippet? I checked out the Content-Disposition header on google. Interestingly, one of the posts on one site suggested
response.setHeader("Content-Disposition" , "Mohammed; filename=\"MailingLists.pdf\"");
The post, whose name is Mohammed, went as far as saying we can use our own name in place of Muhammed. Some other posts said we can use
response.setHeader("Content-Disposition" , "attached; filename=\"MailingLists.pdf\"");
What does the first field of the second parameter in response.setHeader() do?
Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Whoops! I had a 1 in 3 chance of getting it right. You're correct - my snippet was for a PDF document, but I think you can tell what you'd have to to for Word.
This may help: http://www.faqs.org/rfcs/rfc1806.html
There's a known bug in content-disposition handling for some versions of IE, BTW.
khurram mirza
Greenhorn

Joined: Jun 10, 2001
Posts: 25
tim,is there any possiblity that the file opened in browser from server is saved after modification and it is saved to server from where it is downloaded.apprenetly it is not possible because when save option is clicked the dialogue box appeared to save it on client site.but i have to save it on server side by using save option(not 'save as' because file name can be chenged with this).
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

It's tricky. As I've said here before, a web server is not a file server. Since you're working with a Word document, you might want to see if you can create a VBA macro in the document that causes it to be posted to a file upload servlet or JSP.
I've never tried such a thing, but it's a fairly good bet. It's not likely that Word or Windows is going to have a security barrier to stop you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to open a document in word application using servlet