社区
Web 开发
帖子详情
数据库里的图像显示问题
ymblue_boy
2001-10-09 03:51:33
jsp中,怎样将数据库里的图像显示在页面上?图像字段为Picture 属性:image
...全文
104
4
打赏
收藏
数据库里的图像显示问题
jsp中,怎样将数据库里的图像显示在页面上?图像字段为Picture 属性:image
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ymblue_boy
2001-10-25
打赏
举报
回复
谢谢你.
czb
2001-10-17
打赏
举报
回复
看下我写的吧,我的字段名为photo.你的分数也真少啊。
//photo.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>相片</title>
</head>
<body>
<%
String id=request.getParameter("id");
%>
<img src="/homepage/servlet/photo?id=<%=id%>">
</body>
</html>
//photo.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
public class photo extends HttpServlet
{
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
public void init(ServletConfig conf) throws ServletException
{
super.init(conf);
try{
Class.forName("org.gjt.mm.mysql.Driver");
}catch(ClassNotFoundException e){}
String url="jdbc:mysql://localhost:3306/Sample?user=root;password=";
// String user="root",password="";
try{
conn=DriverManager.getConnection(url);
pstmt=conn.prepareStatement("select photo from person where id=?");
}catch(SQLException e){System.err.println("Something is error!");}
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
int id=Integer.parseInt(request.getParameter("id"));
int length;
InputStream is=null;
byte[] buffer=new byte[4096];
response.setContentType("images/*");
DataOutputStream os=null;
try{
pstmt.setInt(1,id);
rs=pstmt.executeQuery();
os=new DataOutputStream(response.getOutputStream());
is=rs.getBinaryStream("photo");
}catch(SQLException e){}
while((length=is.read(buffer))!=-1)
{
os.write(buffer,0,length);
os.flush();
}
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
doGet(request,response);
}
public void destroy()
{
try{
rs.close();
pstmt.close();
conn.close();
}catch(SQLException e){}
}
}
ymblue_boy
2001-10-16
打赏
举报
回复
我在网上找了,但资料很少。
redstarstar
2001-10-09
打赏
举报
回复
两种方法:
1.从数据库中用流将图像读出来,写成文件放在服务器端,再在jsp中给出图像的地址。
2.从数据库中用流将图像读出来,通过servlet直接将图像输出到网页(这种方法你查查书)
PHP5+MySQL网站开发实例精讲 源码
以及对MySQL
数据库
进行查询、删除、更新和排序等基础开发知识,还包括在PHP中创建
图像
、使用会话等较深入的开发内容,并在“常用模块编程和综合案例开发”篇中给出了常用模块(如通信录模块、计数器模块、文件上传...
Qt 一去丶二三
里
Blog(一)
例如,QPushButton用于创建按钮,QLineEdit用于文本输入,QLabel用于
显示
文本或
图像
。 Qt的布局管理是另一个重要的主题。QLayout类用于自动调整控件的位置和大小,以适应窗口的变化。有多种布局类型,如QVBoxLayout...
emoji图片和编码表
在提供的文件`ios_emoji2012-05-17.sql`中,很可能是包含了当时苹果iOS系统emoji
数据库
的一个快照,可能包含了emoji的Unicode码点、对应的
数据库
ID以及其他相关信息,这对于分析早期iOS系统的emoji实现和演化非常有...
Qt下使用Sqlite
数据库
实现
图像
的读写
显示
在Qt中使用Sqlite
数据库
可以保存很多类型的数据,其中还可以用来保存
图像
,这
里
对
图像
的保存和读取
显示
功能进行讲述,并将相关代码展现出来以便大家学习,如有错误之处,欢迎大家批评指正。
数字
图像
处理(7):爬虫建立
数据库
并实现
图像
检索
文章目录爬虫建立
数据库
图像
检索1、使用平台及语言2、
图像
检索操作流程2.1点击 选择检索
图像
按钮2.2选择
数据库
路径2.3点击直方图检索2.4人脸检测与识别(待添加)3.此应用程序用途上周作业遗留
问题
:彩色直方图检索...
Web 开发
81,115
社区成员
341,731
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章