在jsp用一个<img>标签行不行?

解决方案 »

  1.   

    这个easy!
    ------------------------------------------------------------------------------------------
    java:
    GetDocImg.java:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.streammanager.*;import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.rpc.ParameterMode;
    import java.util.*;
    import java.net.*;
    import java.util.*;
    import org.xml.sax.*;
    import java.io.*;public class GetDocImg extends HttpServlet {
      private static final String CONTENT_TYPE = "image/jpeg";  StreamLibrary oStream = new StreamLibrary();
      /**Initialize global variables*/
      public void init() throws ServletException {
      }
      /**Process the HTTP Get request*/
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String kkk = "";
        byte b[]  = new byte[1024];
        try{
          goldshield_fzcweb.JClientDataSet jcd = new goldshield_fzcweb.JClientDataSet();
          String docid = request.getParameter("docid");
          kkk = (String)jcd.getValue("getSltBTImage", new Object[]{new Integer(docid)});
          b = oStream.getPictureBytes(kkk);
        }catch(Exception ex)  {
        }
        response.setContentType(CONTENT_TYPE);
        javax.servlet.ServletOutputStream out = response.getOutputStream();
        out.write(b);
      }
      /**Clean up resources*/
      public void destroy() {
      }  public GetDocImg() {
        try {
          jbInit();
        }
        catch(Exception e) {
          //e.printStackTrace();
        }
      }
      private void jbInit() throws Exception {
      }
    }
    ------------------------------------------------------------------------------------------
    jsp:
    <tr> 
    <img src="servlet/GetDocImg?docid=<%=vDOCID.elementAt(i)%>">
    </tr>
    ------------------------------------------------------------------------------------------