In my web-app I have a servlet that acts as the index. It is bound/mapped to “index.jsp” (index.jsp doesn’t actually exist) but it is called “Index.java”. The client can go to index.jsp (which will go through the servlet) but if the client tries to go to Index.java directly it will say it can’t find the resource. Why is this?
I know that files/folders inside of WEB-INF/META-INF aren’t accessible to clients but why aren’t .java files? I mean, it makes sense (because you SHOULDN’T be able to go to them directly.) but what is happening to prevent the user from gaining access?
Normally, all java classes are compiled to
.classfiles (and might be placed in a jar) and placed underWEB-INF/classesorWEB-INF/liband therefore, is unable to be accessed by public (since everything underWEB-INFis not publicly accessible).Furthermore, unless you explicitly included the
.javasource codes into the war (when you build the war), you won’t even find the.javafiles (in your case, theIndex.java) in the servlet container.