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



Home Answers Viewqa Java-Beginners retrieving image from mysql db with standard height and width
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sujitha
retrieving image from mysql db with standard height and width
0 Answer(s)      a year and 10 months ago
Posted in : Java Beginners


Hi . Here is my code to retrieve an image from mysql db. Its working properly. But i want the image with specified width and height. How to specify it in this code.

 Thanks in advance.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="javax.servlet.http.HttpSession"%>
<%@ page language="java"%>
<%@ page session="true"%>
<%
  try{
  //PrintWriter out=response.getWriter();

  out.println("Retrieve Image Example!");
  String driverName = "com.mysql.jdbc.Driver";
  String url = "jdbc:mysql://localhost:3306/";
  String dbName = "db";
  String userName = "root";
  String password = "root";
  Connection con = null;
  Class.forName(driverName);
  con = DriverManager.getConnection(url+dbName,userName,password);
  Statement st = con.createStatement();
  PreparedStatement pre = con.prepareStatement("select * from image");
  ResultSet rs=pre.executeQuery();
  if(rs.next())   
  {byte[] bytearray = new byte[4096];  
               int size=0;  
              InputStream sImage;  
                sImage = rs.getBinaryStream(2);  
                response.reset();  
                response.setContentType("image/jpeg");  
                response.addHeader("Content-Disposition","filename=logo.jpg");  
                while((size=sImage.read(bytearray))!= -1 )  
                  {  
                    response.getOutputStream().write(bytearray,0,size);  
                  }  
                response.flushBuffer(); 
                sImage.close();  
                rs.close();  
             }      
 out.println("Retrieved Successfully!");
  pre.close();
  con.close();  
  }
  catch (Exception e){
  out.println(e.getMessage());
  }
%>
</body>
</html>

Advertisement
View Answers

Related Tutorials/Questions & Answers:
retrieving image from mysql db with standard height and width
retrieving image from mysql db with standard height and width  Hi . Here is my code to retrieve an image from mysql db. Its working properly. But i want the image with specified width and height. How to specify it in this code
retrieving image from mysql db with standard height and width
retrieving image from mysql db with standard height and width  Hi . Here is my code to retrieve an image from mysql db. Its working properly. But i want the image with specified width and height. How to specify it in this code
Advertisements
image height width php - PHP
image height width php  I am digging for the PHP Script to set the height and width of Image in my app
get image height and width html
get image height and width html  How to get image height and width in html?    var img = new Image(); img.src = your_src img.width img.height
Storing and retrieving data alongwith image in mysql db using jsp
Storing and retrieving data alongwith image in mysql db using jsp  I want to store and retrieve the whole data as shown below in mysql db. I've put... as it is really important for my project????? THIS IS MY DB Table. mysql> use
Store image from html img tag into mysql db using java
Store image from html img tag into mysql db using java  Hi. How to get the image displayed in the < img > tag of HTML and store it in the mysql database using java? Thanks in advance
retrieving from db - JSP-Servlet
retrieving from db  hello' I am trying to write my first application...: rst=stmt.executeQuery("select * from books_details"); 27: %> 28...; Hi Retrive value from database Retrive data from
How can we get the properties (size, type, width, height) of an image using php image functions?
How can we get the properties (size, type, width, height) of an image using php image functions?  How can we get the properties (size, type, width, height) of an image using php image functions
UIImage width and height
UIImage width and height  Hi, How I can find the width and height of UIImage object. Let's know an example code for finding UIImage width and height. Thanks
retrieving info from DB using struts?
retrieving info from DB using struts?  Hi. I was looking info about retrieving info from a database using struts. I need a .java that I suppose connects to a database and show the info on a jsp. Somebody could help me
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
Saving image and text in mysql db using spring?
Saving image and text in mysql db using spring?  Hii, My requirement is to save the employee details(including image) into mysql db.i want to save the image location in db .And actual image(binary formate) should save
HTML5 video height width.
HTML5 video height width. Introduction:The <video> tag use for embedding... will introduce you to about the height and width attribute . They define height... Description height pixel Define height of media. width pixel
View Photo From Db MySql
View Photo From Db MySql  Good Morning Sir, Please help me, I make a small code but i have a error. I want to make viewer photo from database MySql into my project in netbeans. this is my code : try
Image retrieval from mysql - JSP-Servlet
Image retrieval from mysql  Hai friends, I used the following code to insert image into mysql db. Db data type is blob.... Inserted file image does not exist database limit. But, while retrieving image
UIView frame x,y width and height
UIView frame x,y width and height  HI, How to print the x,y width and height of UIView? Thanks   Hi, Following code can be used: CGRect myFrame = myview_.frame; NSLog(@"height = %f", myFrame.size.height); NSLog
retrieving image files - JSP-Servlet
retrieving image files  How to retrieve multiple images at a time from mysql database using JSP
Change panel height, width and title
Change panel height, width and title         With the help of a button's click we can change the height, width , and title of a panel. In the given tutorial
Setting the Height and Width of Rows and columns in JTable
Setting the Height and Width of Rows and columns in JTable... tutorial you will learn how to set the height and width of rows and columns... and width for containing the data. JTable provides some specified height
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink
Retrieving images from the oracle database using jsp and create that rretrieved image as hyperlink  I want to insert images into oracle database.I want to retrieve images using jsp and I want to display on the browser.The
CSS problem height from top
CSS problem height from top  here i wrote a code but can you tell me how to increase height from top <html> <head> <style type="text/css"> .hello img { height : 100px; width :100px; margin-top
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page...="#ffe9bf" cellPadding="0" cellSpacing="0" width="658" height="63"> <tbody> <td bgColor="#008080" width="47" align="center" height="19"><
Image in mysql
Image in mysql  Hi. How to insert and retrieve images in mysql db using JSP or JAVA Servlet? Thanks in advance
How To Retrieve Image From From MySQL Using Java
How To Retrieve Image From From MySQL Using Java In this section we will discuss about how to retrieve image from the MySQL using Java. This example explains you about all the steps that how to retrieve image from MySQL database
Retrieving cells in MySQL - JDBC
Retrieving cells in MySQL  Hi, Am creating an online exam application using JSP & MySql.The exam is of objective nature with four choices each and 100 questions. Can you please help me to insert the chosen choice into cells
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...;% Connection connection = null; String connectionURL = "jdbc:mysql://localhost
access image from ajax store in mysql using jsp
access image from ajax store in mysql using jsp  access image from ajax store in mysql using jsp (code to access image captured by camera and store in mysql
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.  Initially,display 7or10 records on a jsp pageand when click on the NEXT button(or href link) then display next 7 records
how to migrate java db to mysql
how to migrate java db to mysql  I have an aplication,for migrating java db to mysql db.how it will done
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
Advertisements
 

 

 

DMCA.com