0

I use following code in HttpServlet.

String pathToWeb = getServletContext().getRealPath(File.separator);

I have application where above code is working fine and return the real path of application directory. Whereas I send another branch for QA and not able to detect the real-path using above code.

which is always return null, using java8,tomcat8 on windows server. Please assist.

I already gone through question like this but not able to find out the solution.

Amol Patil
  • 985
  • 2
  • 11
  • 43

1 Answers1

1

Use / for the path of the context root:

getServletContext().getRealPath("/")

instead of the OS-specific file separator.

wero
  • 32,544
  • 3
  • 59
  • 84