• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

opening document using if statement  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!