0

I have a java dynamic web application being developed in eclipse. My project root is VT. Under WebContent I place a file called cat.jsp. In chrome I can access the file with http://localhost:8080/VT/cat.jsp and the file displays correctly.

eclipse provides 2 subfolders under WebContent. One of them is WEB-INF. In that folder I create a subfolder jspStatic and in there I place a copy of cat.jsp

When I try to access the file in chrome with http://localhost:8080/VT/WEB-INF/jspStatic/cat.jsp I'm getting a file not found 404 error

DCR
  • 14,737
  • 12
  • 52
  • 115
  • for java web applications - any content under `WEB-INF` is not directly accessed from the browser. Only the internals of the web application can access it. This is by design. " This directory is protected by the web server, and its contents are not visible to outside users of the application" src: https://www.oreilly.com/library/view/learning-java-4th/9781449372477/ch15s03.html – blurfus Mar 21 '19 at 17:28
  • ahh, that would do it. although in cat.jsp I have src='WEB-INF/videos/cat.mp4' and it finds it with out any problem – DCR Mar 21 '19 at 17:29
  • Yes, your application can access its contents but not outside users (that's the point) – blurfus Mar 21 '19 at 17:31
  • @ochi Your linked question is certainly relevant, but it does not mention the HTTP 404 error, so (arguably) this question is not a duplicate. – skomisa Mar 21 '19 at 18:00
  • @skomisa actually, very relevant. Since the resource (JSP) is protected by virtue of being inside the `WEB-INF` folder (thus, the user/browser cannot see it) the resulting code (404 - not found) is very applicable. Returning another code (like 401 - access denied, etc) would allow to outside users to guess (trial/error) the internal structure of your application. – blurfus Mar 21 '19 at 18:03
  • @ochi My point was simply that nowhere in the very relevant question/answers you linked to was there any mention that accessing resources within WEB-INF would result in a 404 error, which is specifically the concern of the OP. I think that [JSP in /WEB-INF returns “HTTP Status 404 The requested resource is not available”](https://stackoverflow.com/q/2386031/2985643) might be a closer match as a duplicate of this question. – skomisa Mar 21 '19 at 18:17
  • @skomisa gotcha! Feel free to link to that one as a dupe instead:) – blurfus Mar 21 '19 at 18:25

0 Answers0