title: source code to store image into MySql database and retrieve it and display in Jsp using technologies servlet and Hibernate
body: <p>I have the code to store image into database..that i have completed. But the problem is to  fetch image to my jsp page. Please help!</p>
  
  <pre><code>PrintWriter pw=response.getWriter();
          response.setContentType("text/html");
          MultipartRequest m = new MultipartRequest(request, "d:/workspace/zqa/WebContent/images");
          String name1=m.getParameter("name");
          String address=m.getParameter("address");
          String state=m.getParameter("state");
          String country=m.getParameter("country");
          System.out.print(name1+address+state+country);
          String p=m.getParameter("phone");
          int phone=Integer.parseInt(p);
  
    //      Blob b1=(Blob) m.getFile("filename_1");
  
      boolean isMultipart = ServletFileUpload.isMultipartContent(request);
      if (isMultipart) {
          FileItemFactory factory = new DiskFileItemFactory();
          ServletFileUpload upload = new ServletFileUpload(factory);
          try {
              List items = upload.parseRequest(request);
              Iterator iterator = items.iterator();
              while (iterator.hasNext()) {
  
              }
          } catch (FileUploadException e) {
              e.printStackTrace();
          } catch (Exception e) {
              e.printStackTrace();
          }
     }
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
      ObjectOutputStream oos = new ObjectOutputStream(baos); 
      byte[] personByteArray = baos.toByteArray(); 
      Details ds=new Details();
      ds.setName(name1);
      ds.setAddress(address);
      ds.setState(state);
      ds.setCountry(country);
      ds.setPhone(phone);
     Blob b = (Blob) Hibernate.createBlob(personByteArray); 
      ds.setImage(b);
      SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); 
      Session session =sessionFactory.openSession(); 
      Transaction tx = session.beginTransaction(); 
      session.save(ds); 
      tx.commit(); 
      pw.print("successsss");
  </code></pre>