File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletContext getResource(String path) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletContext getResource(String path)" Watch "ServletContext getResource(String path)" New topic

ServletContext getResource(String path)

Zhiyong Sun

Joined: Nov 24, 2002
Posts: 4
The path MUST begin with a "/" and is interpreted as relative to the current context root. This is defined in the Servlet API.
However, I tested this funciton without "/" and it still works fine. Also, in the example code from that Minning Published SCWCD Study Kit, it also did not use "/".
Can anybody clarify this?
Brusk Baran
Ranch Hand

Joined: Nov 15, 2001
Posts: 132
Did you reload the class then after having changed and re-compiled?
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
It is well possible that some servlet engines are more lenient than the specification. Does it matter?
- Peter
I agree. Here's the link:
subject: ServletContext getResource(String path)
It's not a secret anymore!