Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does servletContext.getRealPath returns null on tomcat 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?

like image 517
gstackoverflow Avatar asked Aug 25 '15 07:08

gstackoverflow


1 Answers

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

servletContext.getRealPath("/resources/images/video_icon.png")
like image 83
gstackoverflow Avatar answered Oct 23 '22 17:10

gstackoverflow