7 Replies Latest reply on Jul 9, 2012 2:47 PM by 903917

    Transferring video files between servlets


      How to transfer the video files between 2 servlets? Similarly how to implement a Live streaming web application in J2EE?
      Which web app. framework does have a better support for the live streaming? Please clarify.

        • 1. Re: Transferring video files between servlets
          Guys no response to this?
          • 2. Re: Transferring video files between servlets
            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.
            • 3. Re: Transferring video files between servlets
              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.
              • 4. Re: Transferring video files between servlets
                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.
                • 5. Re: Transferring video files between servlets
                  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.

                  • 6. Re: Transferring video files between servlets
                    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.
                    • 7. Re: Transferring video files between servlets
                      Let's say you have an Oracle database table named MEDIA with the following records...

                      ID PATH
                      1 media/video/1.mp4
                      2 media/video/2.mp4

                      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...
                            <title>My Media Page</title>
                         <%@ page import="com.MediaDAO" %>
                            MediaDAO mdao = new MediaDAO();
                            <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!
                      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...

                      For more on using the HTML5 audio and video elements, see https://developer.mozilla.org/en/Using_HTML5_audio_and_video