File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes How to open word and pdf document in the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to open word and pdf document in the browser" Watch "How to open word and pdf document in the browser" New topic

How to open word and pdf document in the browser

Bonny Sen

Joined: May 09, 2006
Posts: 26
Hello Friend,

Could any one please suggest a way of opening/viewing a word file or a pdf file in the browser. I am using JBoss 4 server and struts 1.2

The file can be opened in 2 ways:

1. Display the file name on the jsp page as a hyper link. On clicking the link the appropriate file should be opened for reading in the same browser.

2. There would be a radio button against the file name and a "View" submit button. Selecting the file by checking the radio button and clicking on the "View" button should open the file in the browser.

Please help.

With Love, Bonny
"Life is like an ice-cream, Enjoy it before it melts..."
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

While either approach is fine, I always prefer an approach that shows the user what type of file they will be getting upon clicking. In this case, it sounds like #2.

Note that whether it opens in the browser is dependent on the user's configuration. For example, I have .doc files set to prompt for download on my computer.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Swaroop Kunduru
Ranch Hand

Joined: May 22, 2006
Posts: 37
Can someone Please help with a code snappet to open an MsWord using struts framework.

Thanks in advance.


Swaroop Kunduru.

Swaroop Kunduru
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Struts is server-side library, while documents tend to be opened on the client; what are you trying to do - stream the document to the client?
I agree. Here's the link:
subject: How to open word and pdf document in the browser
It's not a secret anymore!