image displaying from database with some other information

Ads
 

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

Ads









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 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 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
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
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
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
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
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
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
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 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
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
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
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
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
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
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
<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
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

Ads