image displaying from database with some other information

image displaying from database with some other information

hi, in the following section of code when i am not displaying the image it is working properly but when i tried to display the image nothing is displayed on browser only a cross mark is shows. same code runs if i am not retriveing any data from admin table my image table has two entries img blob and and id rest have admin table entries.

<%@ page import="java.io.*"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
    <form>
        <%@page import="java.sql.*" %>

        <%
        HttpSession ses=request.getSession(false);

         int admin_id=Integer.parseInt(ses.getAttribute("admin").toString());

            Connection con=null;
            PreparedStatement smt1 = null;
            ResultSet rs1 = null;           
try{

    Class.forName("com.mysql.jdbc.Driver");
               con=DriverManager.getConnection("jdbc:mysql://localhost:3306/online","root","root");
          // smt=con.prepareStatement("select aname,aemail from admin where admin_id=?");
               // smt.setInt(1,admin_id);
                //rs=smt.executeQuery();
byte[ ] imgData = null ;

Blob image = null;

  smt1=con.prepareStatement("select img,aname,aemail from image inner join admin on image.id=admin.admin_id where admin.admin_id=?");

  smt1.setInt(1,admin_id);

                rs1=smt1.executeQuery();
               if(rs1!=null && rs1.next())
                {
image = rs1.getBlob(1);

imgData = image.getBytes(1,(int)image.length());

       %>
 <table width="628" height="573" border="0">
    <tr>
      <th width="591" scope="col"><table width="324" border="0">
        <tr>
          <th width="168" scope="col"><font color="white">Name</font></th>
          <th width="146" scope="col">
              <input type="hidden" name="hiddenField"><font color="red"><%=(rs1.getString("aname"))%>
       </font>
        </tr>
        <tr>
          <th scope="row"><font color="white">Admin ID </th>
          <th scope="row"></font>
               <input type="hidden" name="hiddenField"><font color="red"><%=admin_id%>
</font>
</th>
        </tr>
        <tr>
          <th scope="row"><font color="white">Email ID</th>
          <th scope="row"></font>
          <input type="hidden" name="hiddenField"><font color="red"><%=(rs1.getString("aemail"))%>
</font>
          </th>
        </tr>
        <table width="500" border="0">

<td colspan="5" style="background-color:#FFA500;">
<img src="">
<%response.setContentType("image/gif");

OutputStream o = response.getOutputStream();

o.write(imgData);

o.flush();

o.close();
 %>
</td>

        </table>
      </table>
        <p>
</div>
<%
    }
            }
            catch(ClassNotFoundException e)
            {
                out.println("class not found"+e.getMessage());
            }
            catch(SQLException e)
            {
                out.println("sql excep"+e.getMessage());
            }
            finally
            {
                try{
                    if(con!=null)
                        con.close();
                    }
                 catch(Exception e)
                    {
                    }
            }
%>
</form>
</body>
</html>
View Answers









Related Tutorials/Questions & Answers:
image displaying from database with some other information
image displaying from database with some other information  hi, in the following section of code when i am not displaying the image it is working...=con.prepareStatement("select img,aname,aemail from image inner join admin
Displaying file from database
Displaying file from database  I have list of files in my database. I... that corresponding file from database. I have list of file id related to search. I want to retrieve and display all the file using list of file ID. Is there is any other way
Advertisements
get information from database
get information from database  get information from database   Please visit the following links: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml http://www.roseindia.net/sql/mysql-example/select
Fetching image from database
Fetching image from database  I have uploaded image path and image name in database so, now how can i display that image using JSP or HTML page... in database is:E:\1003\54175\20110407121554 image name i have stored
Displaying Database information on the browser.
PHP DATABASE Information Part-5(b): Displaying Data (with the help of PHPMyAdmin) Up to now, we learned how to create database and insert information in the database. In this tutorial, I will show you how to insert the information
displaying data retrieved from a database in a jsp page
displaying data retrieved from a database in a jsp page  the page... none of the required information is displayed except the tagline protected void... sql = "select billid, customerid, billdate, status from customerbills where
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered... these data.plz some one help me..i m going to submit my project next week..  
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered... these data.plz some one help me..i m going to submit my project next week..  
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want to insert data into database and also want to display the things i have entered... these data.plz some one help me..i m going to submit my project next week..  
jfreechart displaying chart from access database
jfreechart displaying chart from access database  I have these 2 codes. array.java----in which i retrieve the values from the database . import... javax.servlet.http.HttpServletResponse; /** * * @author AARUSHI */ class database { int roll; String
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using
How to retrive an inmage from database and displaying it in imgae box - Swing AWT
How to retrive an inmage from database and displaying it in imgae box ...? I want to retrive an image from database and to display it in a small imagebox...(); f.setTitle("Display Image From database"); Image image = f.getToolkit
How to retrieve image from database
How to retrieve image from database  hi........ How to retrieve image from database when it is stored. I have stored image in postgresql and want... but it retrieves as a string and not complete image can u tel me the conversion
How to retrieve and display image from database in Java?
How to retrieve and display image from database in Java?  Hi, I am writing a web application for reading the data from database and displaying.... Please check the it at How to store and retrieve image from database in JSP
store and retrive image from the database
store and retrive image from the database  please provide me... to store and retreive images from sql database using sql commands -how to store and retreive images from sql database using asp.net/c# thanks in advance
Retrieving the Image from a database Table
Retrieving the Image from a database Table Consider a case where we want... to retrieve the image from the database table. You can do it very easily after... the image from the database table in prepareStatement() method of the Connection
Image is not displaying
Image is not displaying  Hii i am using spring javamail with html template to send mail,i am facing that image displaying prob when mail have to cm in gmail,in template just i am giving my current location of image which
forwarding request to a jsp from a filter and displaying image in that jsp
forwarding request to a jsp from a filter and displaying image in that jsp ... correctly, but in login.jsp the image is not displaying. Can you help me in resolving... to this login.jsp from a filter like this request.getRequestDispatcher("login.jsp
displaying image
displaying image  how to upload image and retrieve it form database mysql in php?   Here is an example of uploading image using php. 1)form.html: <form method="post" enctype="multipart/form-data" action="upload.php
store & retrive the image from oracle database
store & retrive the image from oracle database  how can i store the image path in tha database & fetch that image from oracle database
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one... and retrieve image from database in JSP? Thanks   HI, You can use... the image. Check this example: Retrieve image from database using Servlet. Thanks
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
How to retrieve image from database in Servlet?
How to retrieve image from database in Servlet?  Hi, How to retrieve image from database in Servlet? Thanks   Hi, Please check the tutorial Retrieve image from database using Servlet. Thanks
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
retriving image from database - JSP-Servlet
retriving image from database  how to retrive image from mysql database by using servlet programming  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/retreiveimage.shtml Thanks
To retrieve image from SQL Server Database - Java Server Faces Questions
To retrieve image from SQL Server Database  Sir/Madam, I am trying to retrieve image from SQL Server 2000 database in Visual Web JSF Page using... or in Image Component. please help me in retrieving and displaying image from SQL Server
image displaying in java
image displaying in java  how to display an image by using load image button in applet viewer
how to store and retrieve image from database
how to store and retrieve image from database  how to store and retrieve images into database(oracle) and how to retrive images from database using jsp   Here is a jsp code that insert and retrieve image from mysql
store and retrive image from database - JDBC
()); } } } For retrieve image from database visit to : http...store and retrive image from database  how to store and retrive an image in database using java?  Hi friend, Code for store image
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I need to retrieve the records from the database for every 7 seconds and display... data from the database. After getting the response from the servlet am unable
Retrieving Information From Database in JSF Framework - Development process
Retrieving Information From Database in JSF Framework  Requirement... retrieved from database. see how the datatable in select.jsp should be http......... and the connection to database should use via datasource please answer
how we retrieve image from database
how we retrieve image from database  my code is:- $search=$_POST... from mysql database: <?php mysql_connect("localhost","username","password... not connect to Database"); $query = "SELECT content,size,type FROM upload WHERE id=1
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database...){e.printStackTrace();} } %> 3)For oracle database, use BLOB datatype for image
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
image is display from path of mysql database
image is display from path of mysql database  <%@ page import="java.io.,java.sql.,java.util.zip.*" %> <% String saveFile=""; String contentType = request.getContentType(); if((contentType != null)&&
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I am total new to JSP although I am learning it for the last few days. Now I want to use MySQL Database from JSP page. How to retrieve image from database using
how to display image and text in single jsp page from the mysql database
how to display image and text in single jsp page from the mysql database  hello please help me to display the image and text in single jsp page from mysql database if have any reference code please send me Thanks in advance
how to show image as a link which path coming from database
how to show image as a link which path coming from database   iam not getting proper answer for it. I am using netbeans .the url coming instring from database ,want to display as image on jsp . please help me
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  How to copy an image from one folder to another folder using jsp
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
Displaying image using jsp and spring.
Displaying image using jsp and spring.  how to display an image stored in WEB-INF/images folder on the browser using jsp and spring
displaying image in awt - Java Beginners
displaying image in awt  Hi All, I have downloaded the code to display image using awt from here and when I execute the code I am getting... found : java.awt.Image required: Image image = tool.getImage("D
Retrieve image from mysql database through jsp
Retrieve image from mysql database through jsp... to retrieve image from mysql database through jsp code. First create a database... Note : In the jsp code given below, image will be retrieved from database
how to send and retrieve image along with text to and from database
how to send and retrieve image along with text to and from database  im using app engine and i have two logics from different sources and i want to combine them. ive used the greeting example from app engine and i have a random
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  hello, i am creating photo gallery where from admin side i allow admin to browse... be in my image folder...so,How to copy an jpeg image from one folder to other
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me
displaying List of records from database in a jsp using ajax, onclick it should display the results ?? its urgent can u help me   displaying List of records from database in a jsp using ajax, onclick it should display the results

Ads