aspose file tools*
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
JavaRanch » Java Forums » Java » JSP
Bookmark "opening document using if statement" Watch "opening document using if statement" New topic
Author

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 {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc dbc:AcessCore");
publicationNumber = request.getParameter("id");
out.println(publicationNumber);
if(publicationNumber=="NNR1")
{
??? how do I open a specfic document when you click on the link?
}
else if(publicationNumber=="NRR1")
{
href="C://hello.doc"; doesn't work
}
rs.close();
s.close();
con.close();
}
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.
Thanks
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 java.io.InputStream


comp.lang.javascript FAQ: http://jibbering.com/faq/
 
 
subject: opening document using if statement