When your path is inside the webapp context, use application.getRealPath("/")
:
<% String paths = application.getRealPath("/") + "abc.txt"; %>
Question
I want define a path inside a jsp file
<% String paths = "/test/abc.txt"; %>
but it always shown me - file cannot be found error
I'm using tomcat8 server and my index.jsp file placed in the same level of txt file, all inside test folder.
webapps/test/index.jsp
webapps/test/abc.txt
La solution
When your path is inside the webapp context, use application.getRealPath("/")
:
<% String paths = application.getRealPath("/") + "abc.txt"; %>