jsp

位置:IT落伍者 >> jsp >> 浏览文章

用JSP实现数据库图片的存储与显示实例[3]


发布日期:2024年03月03日
 
用JSP实现数据库图片的存储与显示实例[3]

<%@ page contentType=text/html;charset=gb%>

<%@ page import=javasql* %>

<%@ page import=javautil*%>

<%@ page import=javatext*%>

<%@ page import=javaio*%>

<jsp:useBean id=conn scope=page class=dbconnDBResult/>

<%

String path = requestgetContextPath();

String basePath = requestgetScheme()+://+requestgetServerName()+

:+requestgetServerPort()+path+/;

%>

<!DOCTYPE HTML PUBLIC //WC//DTD HTML Transitional//EN>

<html>

<head>

<base href=<%=basePath%>>

<title>My JSP testimageoutjsp starting page</title>

<meta httpequiv=pragma content=nocache>

<meta httpequiv=cachecontrol content=nocache>

<meta httpequiv=expires content=>

<meta httpequiv=keywords content=keywordkeywordkeyword>

<meta httpequiv=description content=This is my page>

<!

<link rel=stylesheet type=text/css href=stylescss>

>

</head>

<body>

<%

int id= IntegerparseInt(requestgetParameter(picid));

String sql = select pic from p WHERE picid=+id;

ResultSet rs=conngetResult(sql);

while(rsnext())

{

ServletOutputStream sout = responsegetOutputStream();

//图片输出的输出流

InputStream in = rsgetBinaryStream();

byte b[] = new byte[xa];

for(int i = inread(b); i != ;)

{

soutwrite(b);

//将缓沖区的输入输出到页面

inread(b);

}

soutflush();

//输入完毕清除缓沖

soutclose();

}

%>

</body>

</html>

[] [] [] []

               

上一篇:用JSP实现数据库图片的存储与显示实例[4]

下一篇:用JSP实现数据库图片的存储与显示实例[2]