1

i am trying to create a jsp page that has a video

<body>
Hello

<video width="400" controls>
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<p>
Video courtesy of 
<a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.
</p>


</body>

this works in tomcat 8.5, but when i move it to my project in jboss 6.4 ie 11 throws the error

AUDIO/VIDEO: Unknown MIME type.

i added the Mime type to my projects web.xml as:

<mime-mapping>
    <extension>mp4</extension>
    <mime-type>video/mp4</mime-type>
</mime-mapping>

can i add the mimetype to the standalone.xml?? or what is my problem?

jaramator
  • 310
  • 1
  • 13
  • Have a look at this, you shouldn't need to deal with the standalone.xml, this SO is where I helped someone with a similar problem [wildfly undertow file mimetypes](https://stackoverflow.com/questions/48659014/wildfly-undertow-file-mimetypes/48665764#48665764) it is wildfly, but that shouldnt matter – JGlass Apr 27 '18 at 15:53
  • I have edited the question and added snippet of the xml and it still throws the error. – jaramator Apr 27 '18 at 19:11
  • this may sound like a stupid question. is there an order i must follow for the mime type? i am putting it after sesion config and before welcome file list – jaramator Apr 30 '18 at 16:26
  • I dont believe there's any ordering, unless your duplicating "mp4" as an extension. I do see this "Apparently the mp4 causes issues with some browsers" from 2016. You're not testing in Safari are you, also what browsers have you tried? Also, in standalone.xml try adding this in host element of undertow `` and then add this `` in filters element of undertow - but I dont think you should have to. Also check the headers being sent. – JGlass May 01 '18 at 14:39
  • sorry, I am not very knowledgeable in JBoss I can't find the undertow tag or host tag, where do I need to put it again? and the response header is of the file video/mp4 – jaramator May 02 '18 at 16:02
  • Added an answer, let me know if it works out for you! You will need to restart JBoss – JGlass May 03 '18 at 14:24

2 Answers2

1

Note backup your standalone or domain xml files prior to trying this modification!

Undertow is actually part of JBoss EAP 7, for JBoss EAP 6 find this section in standalone.xml (if you're using standalone mode, if domain mode look for domain.xml)

    <subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
        <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
        <virtual-server name="default-host" enable-welcome-root="true">
            <alias name="localhost"/>
            <alias name="example.com"/>
        </virtual-server>
    </subsystem>

And add this entry

<configuration>
     <mime-mapping name="mp4" value="video/mp4"/>
 </configuration>

In the end, your web subsystem should look like this

    <subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
        <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
        <virtual-server name="default-host" enable-welcome-root="true">
            <alias name="localhost"/>
            <alias name="example.com"/>
        </virtual-server>
        <configuration>
            <mime-mapping name="mp4" value="video/mp4"/>
        </configuration>
    </subsystem>

Do not copy the entire section above verbatim and paste over what already exists as the web version, elements and attributes may be different, just add the configuration section.

Update - turns out I didn't really need to add the mime type headers, at least when testing in Chrome - the video showed fine on the webpage with the following directory structure (note though the OGG format didnt)

enter image description here

JGlass
  • 1,427
  • 2
  • 12
  • 26
  • sorry but it didn't. I was checking the other config files and the logs to get a clue of what went wrong. – jaramator May 07 '18 at 14:29
  • what I found out is that even if I put the direct link to the file, the server doesn't download the movie, is that common? I mean the server "can't" find the file if the makes sense. – jaramator May 07 '18 at 14:37
  • I'm now thinking theres something else possibly wrong with your app. I created a dynamic war project, added an index.jsp page with basically nothing in it, I download two (believe it or not, the same ones you were testing with) videos and put them in the `WebContent` folder, basically same location as the index.jsp. I then pasted your code in. I made no changes to web.xml or standalone.xml, e.g. I didnt add the mime type header anywhere. I deployed the war, navigated to the URL, and the video shows and plays on webpage in chrome - so check your deployment once deployed to server, – JGlass May 07 '18 at 15:40
  • I added an image of what your WAR should look like after deployment! – JGlass May 07 '18 at 15:44
  • it seems like I am having other problems, I used an SWF file and it worked... sort of, I had to use the object tag instead of the video tag. and the files are where they are supposed to be. the SWF and the MP4 file are in the same folder. – jaramator May 07 '18 at 20:11
  • Well at least you're closer! Maybe your mp4 file is corrupted, try download the two from thew big buck bunny site again, drop them in your WebContent folder, change the names in your JSP and see if one of them works, e.g. mine wouldnt display ogv but did mp4 - also be sure to try different browsers! – JGlass May 07 '18 at 20:25
1

Finally got my answer. it turns out that right above where I inserted my MIME type there was a section with all the supported MIME types.

The correct way to set up the MIME type in my case was

<servlet-mapping>
    <servlet-name>fileserver</servlet-name>
    <url-pattern>*.mp4</url-pattern>
</servlet-mapping>
jaramator
  • 310
  • 1
  • 13