开发者

Struts 2 Automatically Open .doc or .docx On Download

Might be a duff question, but I'm tired of googling...

I'm working on a Struts 2 Web App that lets users edit .docx files, which are stored on the server. For example, the user clicks EDIT, then the document is sent to him/her. When finished editing the updated file goes back to the server.

Well, this is the idea. I use Struts 2 result type="stream" with contentDisposition set to attachment. This obviously presents the user with the Save dialog. The inline contentDisposition is not an option for Word files - browsers won't load it anyway.

QUESTION 1:

Is there a way to "silently" save the file on the client? Sounds like a security threat to me - but I might be wrong.

QUESTION 2:

Next, ho开发者_Python百科w do I start the downloaded .docx file on the client? Again, I'm dubious that it's easily done (security and all that), but I might be wrong here too. :D

I know that users can live with the save dialog as long as the downloaded document automatically opens up in Word.

Any ideas appreciated.


Is there a way to "silently" save the file on the client? Sounds like a security threat to me - but I might be wrong.

Not using Struts2/HTML/JS. You'd need to create a signed(!) applet which does that and then embed that applet in the web page.


Next, how do I start the downloaded .docx file on the client? Again, I'm dubious that it's easily done (security and all that), but I might be wrong here too.

Also here, use a signed applet. Once you've saved the File in the client side by the applet, it's then as easy as

Desktop.getDesktop().open(file);

as long as the client platform has MS Word installed and associated the doc(x) extension with MS Word.


As a completely different alternative, you can also convert the MS Word docuement to HTML and then present that in a pure HTML edit form (which can easily be generated by JSP/Struts2) and then on form submit convert it back to a MS Word document. That's also basically what Google docs is doing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜