I’m having a problem referencing the location of my track from a jsp. I’ve stored the track location in a Database and when i print the path everything looks fine. Am i missing something in my HTML?
My HTML:
<table width="100%">
<tr>
<td align="center">
<EMBED src=" <%=randTrack.getTrackLocation()%> " autostart=true controller=false hidden=false>
</td>
</tr>
My track is stored as “C:\General\Music\Bellx1 – Flock\Bad Skin Day.mp3” without the quotes in the DB.
Thanks
It has to be a HTTP location, not a local disk file system location. So the
srcneeds to look something like http://example.com/music/foo.mp3 and definitely not C:\music\foo.mp3. Local disk file systems are not going to work due to two reasons:HTML is sent from webserver to webbrowser and runs at webbrowser. The paths are resolved at the webbrowser, not at the webserver. Your web visitors do not necessarily have exactly this file on their C: disk. They might even not have a C: disk at all (linux users).
Even if they have (you would likely be the only one), it won’t work on most browsers because of a security restriction to ignore local resources when the HTML page is served over HTTP.
There are several solutions depending on the webserver you’re using. Easiest would be to just drop the folder in the public webcontent next to the JSP files. If that is not an option for some reason, your best bet would be to create a servlet which gets an
InputStreamof it from local disk file system and writes it to theOutputStreamof the HTTP response. You can find a basic kickoff example in this article.