Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet image displaying from database with some other information

Have Programming Question? Ask it here!
 
 
 


nishant srivastava
image displaying from database with some other information
0 Answer(s)      3 years and 2 months ago
Posted in : JSP-Servlet


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>

Advertisement
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
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
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..  
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
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
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 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
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
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
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 displaying in java
image displaying in java  how to display an image by using load image button in applet viewer
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
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
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
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 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
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
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 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
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
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
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
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
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
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
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
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
<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
displaying data for a single column from Mysql database in the list box in php form
displaying data for a single column from Mysql database in the list box in php form  I have a form in php.want to display data from a single column...('include/functions.php'); $Select = "SELECT * FROM category_master"; $Q = mysql
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
how to retrive other details with an image - Swing AWT
to retrive an image as well as some other values from database.. but only image... time from database? button2.addActionListener(new ActionListener...("Select visitor_firstname,Type_code, image_data from visiting_details where Ticket
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
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
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
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...' of database 'mahendra'. Structure of table 'save_image' First create database named
Displaying image with byte array[] - Java Beginners
Displaying image with byte array[]  Hi Frndz.. As per my requirement i need to show an image by using an byte array object which have image data... this only i have to image , i don't have any Inputstream object. If u have
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
image in database
image in database  how to set image in database and retrieve it using servlet(java)in msaccess
Displaying database values in pdf format
Displaying database values in pdf format  Hi All, I am... the form the values are stored in database,the database name is registration... database values should be shown as pdf or excel format. Thanks in advance
Retrieve image from database using Servlet
Retrieve image from database using Servlet     ... that connects to the MySQL database and retrieves the image from the table. After... applications that retrieves the image from database. You can use this type
to display single row from database and next to display other question - JSP-Servlet
to display single row from database and next to display other question  Hi all, I am using JSP with MYSQL backend. In my project we have 100 questions in database we have to display first question on clicking the button
displaying data from ms excel in form.
some logic on how to link this image from my folder to the image.jpg mentioned...displaying data from ms excel in form.  Hi all, I have a requirement as mentioned below: Requirement: I have stored some data in the ms excel
error in uploading image from jsp to oracle 10g database
error in uploading image from jsp to oracle 10g database  ... try to insert into the image into the database i got the above error please advice how to get rid of error   JSP upload image in Mysql database
 

 

 

DMCA.com