title: Displaying a mysql image on a jsp page
body: <p>I'm trying to present an image taken from mysql in a certain part of my jsp page. The problem is that no matter where put the &lt;%> code, I only get the image and not the rest of the content on the page. I want to get the navigation bar and everything else on top of the image returning from the query result.
  The code:</p>
  
  <pre><code>&lt;%@page import="java.sql.*" %&gt;
  &lt;%@page import="java.io.*" %&gt;
  &lt;%!public static Connection connect(){
      Connection con = null;
      try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
  
  
      con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Imperia","root", "");
      return con;
      } catch (Exception e) {
          throw new Error(e);
      }
  }
  public static boolean close (Connection c)
  {
      try{
          c.close();
          return true;
      }
      catch (Exception e)
      {
          return false;
      }
  }
  %&gt;
  &lt;%@ page language="java" contentType="text/html; charset=windows-1255"
      pageEncoding="windows-1255"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
      &lt;head&gt;
      &lt;script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"&gt;&lt;/script&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
          &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
          &lt;link href="css/styles.css" rel="stylesheet"&gt;
  
          &lt;div id="Imperia_Bank"&gt;
              &lt;p&gt;Imperia Bank&lt;/p&gt;
          &lt;/div&gt;
          &lt;div id = "User" &gt;
          &lt;p&gt; Hello: Administrator &lt;/p&gt;
          &lt;/div&gt;  &lt;div id = "User" &gt;
  
          &lt;/div&gt;
      &lt;script type="text/javascript"&gt;
  
              $(function(){
                  $('.fadein img:gt(0)').hide();
                  setInterval(function(){
                      $('.fadein :first-child').fadeOut()
                          .next('img').fadeIn()
                          .end().appendTo('.fadein');}, 
                  3000);
              });
  
          &lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
  
  
          &lt;div class="navbar navbar-inverse navbar-static-top"&gt;
          &lt;div class="container"&gt;
  
              &lt;a href="#" class="navbar-brand"&gt;Imperia Bank&lt;/a&gt;
  
              &lt;button class="navbar-toggle" data-toggle="collapse"
                  data-target=".navHeaderCollapse"&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span
                      class="icon-bar"&gt;&lt;/span&gt;
              &lt;/button&gt;
  
              &lt;div class="collapse navbar-collapse navHeaderCollapse"&gt;
  
                  &lt;ul class="nav navbar-nav navbar-right"&gt;
  
                      &lt;li class="active"&gt;&lt;a href="homepage.html"&gt;Home&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="Login.html"&gt;Login&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="Register.html"&gt;Register&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="customer.html"&gt;Clients&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="Administrator.html"&gt;Administrator&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="account.html"&gt;Accounts&lt;/a&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;a href="Illustration.html"&gt;Illustration&lt;/a&gt;&lt;/li&gt;
                      &lt;li &gt;&lt;a href="ATM.html"&gt;Atm&lt;/a&gt;&lt;/li&gt;
  
                  &lt;/ul&gt;
  
              &lt;/div&gt;
  
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
          &lt;ul id="navigation"&gt;
  
          &lt;div id="red_line_head"&gt;&lt;/div&gt;
          &lt;div id="main"&gt;
              &lt;td id="description"&gt;
                  &lt;p&gt;&lt;p&gt;&lt;br&gt;&lt;br&gt;Founded in 1992 as a Finance and Securities Company, 
                  Imperia Bank converted into a fully fledged commercial bank in January 1996. 
                  Since then the bank has had a long standing tradition of achieving strong financial performance and carrying out 
                  expansion strategies while successfully focusing on efficient client service delivery.
                  Over the last 20 years, Imperia Bank has achieved a sustained growth in our customer deposit base which is largely attributed to the level of confidence our customers have in the bank and our corporate strategy.
                  Currently we have 23 branches in our expanding branch network across major towns and cities.&lt;br&gt;&lt;br&gt;
                     Imperial Bank will continue to enhance the existing risk management parameters through the effective use of our newly installed and cutting edge core banking system.
                     As part of our growth strategy, we are also continuing to recruit qualified professional staff, and providing appropriate training to our existing human resources to ensure we continue to meet evolving customer demands.
                  &lt;/p&gt;
              &lt;/td&gt;
              &lt;td id="news"&gt;
                  &lt;p&gt;
                  &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;u&gt;NEWS:&lt;/u&gt;
                  &lt;br&gt;&lt;br&gt;
                          &lt;td&gt;    &lt;div class="fadein"&gt;
    &lt;img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg"&gt;
    &lt;img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg"&gt;
    &lt;img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg"&gt;
  &lt;/div&gt;
  
  
  &lt;/td&gt;
  &lt;table border="0" &gt;
      &lt;tr&gt;    
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;&lt;%
      Blob image = null;
  
      Connection con = null;
  
      byte[] imgData = null;
  
      Statement stmt = null;
  
      ResultSet rs = null;
  
      try {
  
      con=connect();
          stmt = con.createStatement();
  
          rs = stmt
                  .executeQuery("select Picture from Imperia.homepage where idpicture= '1'");
  
          if (rs.next()) {
  
              image = rs.getBlob(1);
  
              imgData = image.getBytes(1, (int) image.length());
  
          } else {
  
              out.println("Display Blob Example");
  
              out.println("image not found for given id&gt;");
  
              return;
  
          }
  
          // display the image
  
          response.setContentType("image/gif");
  
          OutputStream o = response.getOutputStream();
  
          o.write(imgData);
  
          o.flush();
  
          o.close();
  
      } catch (Exception e) {
  
          out.println("Unable To Display image");
  
          out.println("Image Display Error=" + e.getMessage());
  
          return;
  
      } finally {
  
          try {
  
              rs.close();
  
              stmt.close();
  
              con.close();
  
          } catch (SQLException e) {
  
              e.printStackTrace();
  
          }
  
      }
   %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;button type="button" id= "Next" onclick= "next()"&gt;&gt;&lt;/button&gt;&lt;/td&gt;
  
  
  
      &lt;/tr&gt;
  
  &lt;/table&gt; 
  
              &lt;/td&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Whats wrong here?</p>