1

html video tag is working when i make a normal html page and load the video in src tag. When it comes to a jsp and accessing the video from video tag in localhost it is throwing the error as :- Not allowed to load local resource:

What could be the solution to this.

Vikas Menon
  • 11
  • 1
  • 6
  • How does your source param look like? If you reference to a local path this might cause the error. Can you provide a code snippet? – swinkler Jan 22 '17 at 09:47
  • Possible duplicate of [Output an image file from a servlet](http://stackoverflow.com/questions/8623709/output-an-image-file-from-a-servlet) – swinkler Jan 22 '17 at 09:49
  • Hey swinkler....here goes the code :- – Vikas Menon Jan 22 '17 at 09:56
  • What is the workaround for this..really need some help here.Thanks – Vikas Menon Jan 22 '17 at 09:58
  • The problem is the "D:/Videos/...." - for security reasons the web server is not allowed to directly access the file system. See the other answer. one simple solution is to put the video(s) inside the web application you deploy under tomcat\webapps\\yourvideo.mp4 and address it relatively. – swinkler Jan 23 '17 at 16:23

2 Answers2

0

Chrome does not allow local resources to be loaded by a web page due to security reasons.

You can serve the local resource from tomcat and use a relative path

 <source src="yourvideo.mp4" 

Or you can disable security using the following chrome launch option --allow-file-access-from-files. By activating this option, Chrome will be able to load files locally.

> "C:\PathTo\Chrome.exe" --allow-file-access-from-files

See alternatives and security considerations in this thread How to launch html using Chrome at "--allow-file-access-from-files" mode?

Community
  • 1
  • 1
pedrofb
  • 30,587
  • 4
  • 69
  • 122
0

I finally found the answer . In order to access static resource from local host i just set the context doc base in the server xml of tomcat like this :-

<host><Context docBase="D:/Videos/" path="/videos" /></host>

by doing so you can access static resources from any drive then. Thanks for the help !

Vikas Menon
  • 11
  • 1
  • 6