Forums Register Login
opening document using if statement
I tried to attach files to my database for me to be able to retrieve those documents on the web using an id number. I used binary objects but it didn't work.
Now I am using a method to read the id from the web then open the document. I think it can work but I don't know how.
On the jsp page I have :
out.write("href='PublicationDetails.jsp?id="+ publicationNum + "'>"+publicationNum+"
Then on the other hand :
try {
Connection con = DriverManager.getConnection("jdbc dbc:AcessCore");
publicationNumber = request.getParameter("id");
??? how do I open a specfic document when you click on the link?
else if(publicationNumber=="NRR1")
href="C://hello.doc"; doesn't work
catch (ClassNotFoundException e1) { }
catch (SQLException e2) { }
I have like 100 publications and I have to do this one by one. Can someone tell me how to do that? opening the document as a new window.
Any help will be so much appreciated.
you should use a java class to do db lookups and a servlet as a middle man.
"<a href='/filegetter/?id="+id

FileGetter delegates db lookups to another class, DBUtils.
If the lookup is successful, FileGetter forwards to a jsp using a requestDispatcher.
You want to read a binary file and return a string, so make a DBUtils method, static getBinaryData(), that takes a table id, and a key/value pair and returns a string with the contents of the file.
Easier said than done, I know.
Here'a a DB lookup:

To read the file, you'll need a java.io.InputStream

This thread has been viewed 675 times.

All times above are in ranch (not your local) time.
The current ranch time is
Oct 22, 2018 10:20:42.