ServletContext not giving me real path when i want to go up level directory up
Why does ServletContext#getRealPath() not return me correct path if i use ../
This code works :-
System.out.println(context.getRealPath("/"));
开发者_JAVA百科This one doesn't :-
System.out.println(context.getRealPath("/.."));
How can i get one level up directory from getRealPath()?
Why does ServletContext#getRealPath() not return me correct path if i use "../":
To help protect you against requests that use ".." tricks to fetch content that they are not supposed to see; e.g. something like "../../../../../etc/passwd".
If you want to refer to a directory outside of the servlet context, you will need to create the path another way.
精彩评论