jsp中,想实现声音和文字的同步。
文字存在数据库中,调用显示,声音用的bgsound
运行后,文字能显示,背景声音完全没有,怎么回事啊??
我的程序如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.io.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>从数据库中读取二进制数据</title>
<style type="text/css">
<!--
body {
background-image: url(../pic/beijing.gif);
}
-->
</style><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body>
<bgsound src="1-1-1.mp3">
<p>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();//加载JDBC驱动程序
String url="jdbc:oracle:thin:@localhost:1521:zds32new";
//bin_db为你的数据库的名称
String user="zds32new";
String password="zds32new";
Connection conn=DriverManager.getConnection(url,user,password); //创建数据库连接
String sql="select blob_column from peixun where id='1'"; //查询id为6的binfile字段内容
Statement stmt=null;
ResultSet rs=null;
try{
stmt=conn.createStatement();
rs=stmt.executeQuery(sql); //将查询结果保存到结合rs中
}catch(SQLException e){}
try {
while(rs.next()) {
ServletOutputStream sout = response.getOutputStream(); //声明ServletOutputStream的实例sout
InputStream in =rs.getBinaryStream(1);//获取二进制输入流
byte b[] = new byte[0x7a120];// 创建byte数组用作缓冲
while (in.read(b) != -1)
{
sout.write(b); //输出字符流
}
sout.flush();
sout.close();
}
}
catch(Exception e){System.out.println(e);}
%>
</p>
<div align="center"></div>
</body>
</html>
大家帮看看啊!
想要实现声音与文字的同步显示,还有什么好办法没有啊?
大家帮帮忙。
文字存在数据库中,调用显示,声音用的bgsound
运行后,文字能显示,背景声音完全没有,怎么回事啊??
我的程序如下:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.io.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>从数据库中读取二进制数据</title>
<style type="text/css">
<!--
body {
background-image: url(../pic/beijing.gif);
}
-->
</style><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body>
<bgsound src="1-1-1.mp3">
<p>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();//加载JDBC驱动程序
String url="jdbc:oracle:thin:@localhost:1521:zds32new";
//bin_db为你的数据库的名称
String user="zds32new";
String password="zds32new";
Connection conn=DriverManager.getConnection(url,user,password); //创建数据库连接
String sql="select blob_column from peixun where id='1'"; //查询id为6的binfile字段内容
Statement stmt=null;
ResultSet rs=null;
try{
stmt=conn.createStatement();
rs=stmt.executeQuery(sql); //将查询结果保存到结合rs中
}catch(SQLException e){}
try {
while(rs.next()) {
ServletOutputStream sout = response.getOutputStream(); //声明ServletOutputStream的实例sout
InputStream in =rs.getBinaryStream(1);//获取二进制输入流
byte b[] = new byte[0x7a120];// 创建byte数组用作缓冲
while (in.read(b) != -1)
{
sout.write(b); //输出字符流
}
sout.flush();
sout.close();
}
}
catch(Exception e){System.out.println(e);}
%>
</p>
<div align="center"></div>
</body>
</html>
大家帮看看啊!
想要实现声音与文字的同步显示,还有什么好办法没有啊?
大家帮帮忙。
解决方案 »
- 火狐浏览器request.getSession().getAttribute("User")为空。。在线等解答
- Spring配置多个异构数据源的问题
- 自定义JSP标签的问题
- Notepad++在编译java时左侧的指示框总是显示红色
- 初學jsp,第一個jsp的留言板調試成功,高興.散分,感謝csdn上的月友.
- jbuilder对硬件有什么要求?
- 关于数据库查询
- 请win886688() 领第三个100分
- 为什么我在JavaScript中校验时,取Radio的Value总是Undefined?
- 多人聊天室,websocket实现
- 为什么没有Web App Libraries
- 用户注册后,跳转到首页,把原来在哪的登陆的表单隐藏,在那里显示用户名怎么搞,
限制了背景音乐和图片的输出。
快烦躁死了,一星期没干别的,天天调试它了。
想把声音也存进去的,但是在jsp中读声音文件没成功,所以就用了这种两结合的方法了。
但还是不行啊!!