jsp里面的引用:
<td width="20%" height="126" rowspan="3" bgcolor="#308DBB"> <img src="<%=request.getContextPath()%>/admin/Image.jsp"></td>
Image.jsp
<%@ page contentType="image/jpeg"%> <%@ page language="java" import="java.io.*"%> <%
out.clear(); response.setContentType("image/jpeg"); response.addHeader("pragma","NO-cache"); response.addHeader("Cache-Control","no-cache"); response.addDateHeader("Expries",0); String str="c:/4.jpg"; byte[] myData = null; InputStream input = new FileInputStream(str); try { ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); int ch = 0; while ((ch = input.read()) != -1) { byteArray.write(ch); } myData = byteArray.toByteArray(); } catch (RuntimeException e) { e.printStackTrace(); throw e; } myData = new sun.misc.BASE64Decoder().decodeBuffer(new sun.misc.BASE64Encoder().encode(myData)); System.out.println("myDate.length()="+myData.length); OutputStream toClient=response.getOutputStream(); toClient.write(myData); toClient.close(); %>