熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

用JSP實現數據庫圖片的存儲與顯示實例[3]

2022-06-13   來源: JSP教程 

  <%@ 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>


[]  []  []  []  


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20707.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.