Link to home
Start Free TrialLog in
Avatar of OliviaRedhorse
OliviaRedhorseFlag for United States of America

asked on

How to open a document from a hyperlink on a JSP page?

I am attempting to create a hyperlink where the user can click to view a document, just as read only.  It will be the same document as a reference.  I have created my web application in a MVC design.  I am using JSP as the GUI.  Can anyone guide me with examples and/or suggestions on how to create this function?  Thanks all.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>where the user can click to view a document, just as read only.  

Documents would always be read only in these circumstances

>>It will be the same document as a reference.

Please explain the above
Avatar of OliviaRedhorse

ASKER

The hyperlink will open the same document.
Sorry -  i don't understand - the same as what? All that is necessary is a valid url and the correct handler for that mime type to open the document ...
When a user clicks on a hyperlink, the document will open.  Forget "same".  Sorry for the confusion.
one option is to create another jsp with read only texts and pass the values in the url when opening the page. example: readOnlyPage.jsp?field1=value1&field2-value2...

btw, are you trying to display a print preview page?
I have a document already written.  This is not a print preview page.  I just would like the user to be able to view this document.
>>When a user clicks on a hyperlink, the document will open.

See above. What kind of document is it?
Sorry about that, it is a word document.
try <a href="../worddoc.doc" target="_blank">Open Doc</a>
>>Sorry about that, it is a word document.

As i mentioned earlier: just put a link to the document in
okay, I tried your idea and the first time I tried nothing happened.  Then I copied the document in a new folder I called "files" and I get the HTTP 404 File not available error.  I have changed the path several times and it still cannot find the file.  What am I doing wrong?  Thanks
Put the doc in the same folder as the jsp and refer to it as <a href="x.doc">Open it</a>
ASKER CERTIFIED SOLUTION
Avatar of cezarF
cezarF
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have tried both of your ideas and I continue to get the 404 message.  This is the last thing I tried.

<a href="https://server:port/openDocTest/test.doc">User Manual</a>
Check the path
I do have real values in the server and the port section.  The test.doc is in the same directory as the jsp pages.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I got it working. Thanks all.
:-)
thanks!