This content has been marked as final. Show 7 replies
Guys no response to this?
Google "file servlet" and you should see how to serve files from a servlet. Transferring between servlets is a bit odd. Servlets are supposed to serve client requests so if a client wants a video they should be linked to the file servlet rather than to some servlet that will forward the request to some other (file) servlet.
Servicing a file is hardly "live streaming" of video :)
The OP is just barking up the wrong tree. You don't want to build this, you want to take an existing solution and USE it; optionally hooking up your own client application to some sort of interface that the server provides.
Whenever I've done streaming of media, whether audio or video, I store the relative path of the file in a database table and then store the actual file in the directory that the path points to. Then, I'll get the path to the media file via ajax or directly in the JSP through a database select. I've employed this technique successfully and have also read others recommend this approach. Also, with HTML5, you can now use the <video> and <audio> tags to embed video and audio on your pages directly.
Thanks Zack. Could you please provide some links on this or any sample example which will be really helpful as this is really an emergency from our side.
How can it be an emergency when you've let it rest for nearly a month?
For the file servlet I would refer to this article as a starting point: http://balusc.blogspot.nl/2009/02/fileservlet-supporting-resume-and.html
No video example directly, but the idea should be the same since you're streaming bytes in all cases.
As for HTML 5 video... that's not a Java question and Google is your friend.
Let's say you have an Oracle database table named MEDIA with the following records...
And you have this directory underneath the web directory of your application:
In your index.jsp file underneath your web directory, you could then access a POJO that retrieves the path to your media object based on a supplied ID. Something like this...
This is a very simple example and you should use JSTL instead of scriptlets but I figure this may get you started down the right track. MediaDAO would be a class used to get the records from the MEDIA table and then supply the individual PATH columns based on a supplied ID. That supplied ID could be a request parameter, select list option, etc...
<html> <head> <title>My Media Page</title> </head> <%@ page import="com.MediaDAO" %> <% MediaDAO mdao = new MediaDAO(); %> <body> <h1>My Media Page</h1> <!-- Simple video example --> <video src="<%= mdao.getVideoPath(1) %>" autoplay> Sorry, your browser doesn't support embedded videos, but don't worry, you can <a href="<%= mdao.getVideoPath(1) %>">download it</a> and watch it with your favorite video player! </video> </body> </html>
For more on using the HTML5 audio and video elements, see https://developer.mozilla.org/en/Using_HTML5_audio_and_video