Q: Where was the “bookCode.jar” JAR file located? In other words, where does the getResourceAsStream() method LOOK to find the file? How do you deal with the path?
A:
A: The getResourceAsStream() requires you to start with a forward slash (“/”) , which represents the root of your web app. Since the web app was named JarDownload, then the directory structure looks like the directories in the picture. The JarDownload directory is inside webapps (as a peer directory to all the other web app directories), then inside JarDownload we put the WEB-INF directory, and the code JAR itself. So the file “bookCode.jar” is sitting at the root level of the JarDownload web app. (Don’t worry, we’ll go into deep penetrating details about the deployment directory structure when we get to the deployment chapter.)