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
Was it helpful?

Solution

When your path is inside the webapp context, use application.getRealPath("/"):

<% String paths = application.getRealPath("/") + "abc.txt"; %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top