wood burning stoves
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem with getResource() method. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem with getResource() method." Watch "Problem with getResource() method." New topic

Problem with getResource() method.

Haiyao He

Joined: Jun 19, 2002
Posts: 1
I wonder if anyone has come across this problem in Manning's book. In listing 4.8 on p53, the line
URL url = context.getResource("files/test");
doesn't work quite well. In fact, you have to add a "/" before "files/test" to make it work.
Another problem is that by this way, it will always download the jar file by the name of the servlet itself. If you want to specify the name of the download file, you have to add another line:
res.setHeader("content-disposition", "attachment;filename=test.jar");
after line:
Can anyone tell me the difference between:
Thanks a lot.

Haiyao He
Dominic Paquette
Ranch Hand

Joined: Dec 13, 2002
Posts: 64
ServetContext.getResource(String path)
The api says that path must start with a slash so it's probably just a type o.
Your other question, I can't answer
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem with getResource() method.
It's not a secret anymore!