8

I have the following code line:

servletContext.getRealPath("resources/images/video_icon.png")

Wen I run application using jetty(using maven plugin) this code line return corect value.

When I run application using tomcat 8(on tomcat 7 it works) - application returns null.

application structure:

enter image description here

1.How to fix it?
2.Why does it happen?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

15

after adding / in the path beginning it works for both: jetty and tomcat 8

servletContext.getRealPath("/resources/images/video_icon.png")
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • The reason is Tomcat requires / at the begining – tangobee May 06 '16 at 06:30
  • Thanks Tangobee , Kindly let me know why tomcat 8 is doing this or you can why this thing is changed. There might be some reason behind this I am investigating that thing. – user1061865 Mar 16 '17 at 10:40