This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JSP and the fly likes opening document using if statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "opening document using if statement" Watch "opening document using if statement" New topic

opening document using if statement

orelia hans
Ranch Hand

Joined: Jan 29, 2004
Posts: 37
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.
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
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

comp.lang.javascript FAQ:
I agree. Here's the link:
subject: opening document using if statement
It's not a secret anymore!