如何使用Servlet或JSP播放视频?
如何使用Servlet或JSP播放视频?
How to play video using Servlet or JSP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何使用Servlet或JSP播放视频?
How to play video using Servlet or JSP?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
在 JSP 中,这与在普通 HTML 中所做的没有什么不同。只需使用
和/或
仅当您尚未将视频文件存储在公共 Web 内容中时,servlet 才有用。但尽管如此,这并没有什么特别的,需要由 servlet 来完成。只需从文件源(固定磁盘上的其他位置或数据库等)读取
InputStream
,并沿着一组正确的响应标头写入响应的OutputStream
。In JSP, it's not different from as you would do in normal HTML. Just use the
<embed>
and/or the<object>
element which points to an URL where the video file is located. You need to consult the documentation of the video format vendor for details how to use it. Since you didn't mention what format the video file is in, we can't help you further in detail. So here's just one example: in case of Quicktime.mov
files, you can consult it at Apple.A servlet is only useful if you haven't stored the video file in public webcontent. But still then, it's nothing special which needs to be done by the servlet. Just read
InputStream
from the file source (somewhere else on fixed disk, or in a database, etc) and write toOutputStream
of the response along a correct set of response headers.