title: how to upload a image in jsp and store database as blob
body: <pre><code>&lt;%@page import="java.sql.*" %&gt;
  &lt;html&gt;
  &lt;form method="get" action="blobexcode.jsp" onsubmit="txtvalidate()"&gt;
  &lt;head&gt;
      &lt;style type="text/css"&gt;
      body{
          background-color:#d0e4fe;
      }
  &lt;/style&gt;    
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Customer Name&amp;nbsp;&lt;input type="text" name="Customername" id="customername"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
           &lt;tr&gt;
              &lt;td&gt;
                  Customer Mob: &lt;input type="text" onkeypress="return 
  isNumberKey(event)" name="Customerphone" id="customerphone" &gt;
              &lt;/td&gt;
          &lt;/tr&gt;
           &lt;tr&gt;
              &lt;td&gt;
                  Upload File:&amp;nbsp;&amp;nbsp;&lt;input type="file" id="f" name="f" &gt;
              &lt;/td&gt;
          &lt;/tr&gt;
           &lt;tr&gt;
              &lt;td&gt;
                  &lt;input type="submit" value="SUBMIT" id="submit"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
       &lt;script type="text/javascript"&gt;
          function isNumberKey(evt)
          {
              var charCode = (evt.which) ? evt.which : event.keyCode
              if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
                 return false;
              else
                 return true;
           }
       &lt;/script&gt;
  
       &lt;script type="text/javascript"&gt;
           function txtvalidate()
           {
              if(document.getElementById("customername").value=="" ||
                 document.getElementById("customerphone").value=="")
              { 
                 alert("Fill all fields");
                 return false;
                 document.Customername.focus();
              }
              else
                 return true;
          }
      &lt;/script&gt;
  
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/form&gt;
  &lt;/html&gt;
  </code></pre>