I have a servlet need to read PDF file from CD and I can get the name of file from the database. My problem is I don't know which name of the CD drive will be used later (d, e, f ...)? Since I can't make the CD drive's name hardcoded in my code, I wonder is there a way to figure it out from the system? Jim
Not every computer has exactly one CD drive, and Java doesn't have a lot of support for hardware sniffing, since that's not easy to do in a system designed for portability. However, you can manually provide the drive ID via a servlet startup parameter and avoid hard-coding it in program logic. Or better yet, put the whole PDF path there, in case you need to move it later.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Jan 09, 2001
I agree with Tim. The init parameter is a good idea, however, I would set up a property file of some sort that has the drive path in it (along with any other application properties), and create a class that reads from that file. This allows you to only have to change the property file when you create the web application on a new machine. The property files and their java counterparts (ResourceBundles) work on Windows, Linux, and Solaris machines. I am sure they would work on any other system that has an updated JVM. Hope this Helps Heath