resize dynamic image in jsp

resize dynamic image in jsp

Sir,
I am saving the images in mysql database with Blob. An I am retrieving the images with this code:-
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="servlets.MySqlConnect" %>
<%
MySqlConnect sc = new MySqlConnect();
Connection con = sc.getConnection();
InputStream sImage;

ServletOutputStream o = response.getOutputStream();
ResultSet rs =null;
Blob image=null;
PreparedStatement psmnt =null;

try{
psmnt = con.prepareStatement("SELECT img FROM Test WHERE img_id = ?");

psmnt.setString(1, "ss");
rs = psmnt.executeQuery();
if (rs.next()) {
image = rs.getBlob(1);
} else {
response.setContentType("text/html");
out.println("<html><head><title>Display Blob Example</title></head>");
out.println("<body><h4><font color='red'>image not found for given id</font></h4></body></html>");
return;
}
response.setContentType("image/gif");
InputStream in = image.getBinaryStream();
int length = (int) image.length();
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
while ((length = in.read(buffer)) != -1) {
o.write(buffer, 0, length);
}
in.close();
o.flush();
}
catch(Exception ex){
out.println("error :"+ex);
}

finally {
// close all the connections.
rs.close();
psmnt.close();
con.close();
}

%>

I am getting my image with this code but all I need that I want to resize that image automatically according to given dimension after retrieving on web page.
If you will help me, I will be very grateful to you.
Thanking You,

Shailander Sharma
View Answers









Related Tutorials/Questions & Answers:
resize dynamic image in jsp - JSP-Servlet
resize dynamic image in jsp  Sir, I am saving the images in mysql...:- I am getting my image with this code but all I need that I want to resize that image automatically according to given dimension after retrieving on web page
Resize image stored in database
Resize image stored in database  hi, Can any one please send code for how to resize image stored in database in blob datatype in jsp, i want to resize it to 140(w)*160(h) please help me
Advertisements
Image Resize in Flex
Image Resize in Flex  Hi....... I am going to add images into a tag. How will it resize itself? Please tell me about that.... Thanks  Ans: The image resize is the part of laying out of your application. you
ModuleNotFoundError: No module named 'image_resize'
ModuleNotFoundError: No module named 'image_resize'  Hi, My Python... 'image_resize' How to remove the ModuleNotFoundError: No module named 'image_resize' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-image-resize'
ModuleNotFoundError: No module named 'python-image-resize'  Hi, My... named 'python-image-resize' How to remove the ModuleNotFoundError: No module named 'python-image-resize' error? Thanks   Hi
ModuleNotFoundError: No module named 'python-resize-image'
ModuleNotFoundError: No module named 'python-resize-image'  Hi, My... named 'python-resize-image' How to remove the ModuleNotFoundError: No module named 'python-resize-image' error? Thanks   Hi
dynamic image change javascript
dynamic image change javascript  How to display images in JavaScript dynamically
need dynamic image example
need dynamic image example  struts 2 img example for a dynamic image.... I am creating a profile for a user and the user is uploading his image which I... this with the image. I need to see an example of how to do this for an image. I am
PHP GD Image Resize
) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0...($tn, $save, 100); echo("Image created and saved successfully."
create dynamic image gallery jquery
create dynamic image gallery jquery  How to create a dynamic image gallery in Jquery
resize image with the change in size of jpanel.. - Java Beginners
resize image with the change in size of jpanel..  hi.. i am try to insert image in jpanel in jform to give attractive look to application,but the of image do not changes if the size of jframe or jpanel changes. if there is any
Dynamic include jsp
Dynamic include jsp  I need dynamic include jsp page with an example
dynamic pagination in jsp - JSP-Servlet
dynamic pagination in jsp  i am unable to display the data in multiple pages. I am gettting data from the database from the javaBeans to jsp by vectors... but i am unable to displaying them in jsp 15 records per page
Dynamic table in jsp
Dynamic table in jsp  Hi..... I have a java file to read excel file... to show all values of excel file on jsp page in a table format. All elements are displaying on jsp page but in vertical line. How can i change them in table
ModuleNotFoundError: No module named 'dynamic-upload-image-field'
ModuleNotFoundError: No module named 'dynamic-upload-image-field'  Hi...: No module named 'dynamic-upload-image-field' How to remove the ModuleNotFoundError: No module named 'dynamic-upload-image-field' error? Thanks
ModuleNotFoundError: No module named 'dynamic-upload-image-field'
ModuleNotFoundError: No module named 'dynamic-upload-image-field'  Hi...: No module named 'dynamic-upload-image-field' How to remove the ModuleNotFoundError: No module named 'dynamic-upload-image-field' error? Thanks
ModuleNotFoundError: No module named 'django-dynamic-image'
ModuleNotFoundError: No module named 'django-dynamic-image'  Hi...: No module named 'django-dynamic-image' How to remove the ModuleNotFoundError: No module named 'django-dynamic-image' error? Thanks   Hi
ModuleNotFoundError: No module named 'dynamic-upload-image-field'
ModuleNotFoundError: No module named 'dynamic-upload-image-field'  Hi...: No module named 'dynamic-upload-image-field' How to remove the ModuleNotFoundError: No module named 'dynamic-upload-image-field' error? Thanks
Dynamic Line draw in JSp
Dynamic Line draw in JSp  In my application. I have one source selected from listbox and multiple targets selected from checkboxes. After submitting... multiple target. And each line should have dynamically link of other jsp page
dynamic display - JSP-Servlet
dynamic display  hi, i want to display dynamic values in drop drown box in a jsp page.these values are in the form of arraylist's object which... javax.servlet.http.*; public class DataServlet extends HttpServlet{ String page="/jsp
JSP: Dynamic Linking - JSP-Servlet
JSP: Dynamic Linking  Hi I am fetching data as a search result from database and displaying it in a table(id and name)using while(rs.next()){...}.I... inside your result set loop to provide them a dynamic link. JSP Code
Dynamic link in JSP
Dynamic link in JSP  Hii everyone...I have stuck from last 2 days... jsp page which contains some checkboxes, so from that checkboxes , i have..._TO_REPLACE_1 So, I have stuck with this LINK ...How to generate this dynamic link n all
JSP:Dynamic Linking - JSP-Servlet
JSP:Dynamic Linking  Hi This is extension to my previous question: " I am fetching data as a search result from database and displaying it in a table(id and name)using while(rs.next()){...}.I want to provide hyper link
Image retrieval in Servlet and JSP
Image retrieval in Servlet and JSP  Sir, How should i give dynamic paths to image in JSP. EX : `<img src="C:\Users\Public\Pictures\Sample... to retrieve the image with name 001.jpg. I have no idea as to how should i
image in jsp - JSP-Servlet
image in jsp  i m storing path of image in my database.. but when i m trying to display image using that path image is not getting... i m storing path like c:\image\a.jpg ... and i m using tag... how to get
jsp image problem - JSP-Servlet
jsp image problem  hi everyone, How to display multiple images from mysql database to jsp page. please help me
display image on jsp
. image is like link. on jsp . i am trieving that image path by which image is downloading on jsp. show i can open it. but i want to display that image on jsp...display image on jsp  how to display image from database which path
Jsp Image prob - JSP-Servlet
Jsp Image prob   I m working on a project i which i have to upload a image in jsp to database and then on next page i will show that image from database so what should i do as i have done first phase
Image preview - JSP-Servlet
Image preview  How to show the preview of the image when we select the image through browse button in JSP page before storing it in the application... select the image using the file type button i want to dynamically show
Objective C resize UIImage
Objective C resize UIImage  i just want to resize the image on the touch detection. That means if a user double clicks on the UIImage it must resize the image
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used for dynamic web applications. In my dynamic web application I want to display the blog image from database. How to retrieve blob image from database in JSP
image display - JSP-Servlet
image display  how to display image that store in mysql database... column have BLOB datatype....  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Thanks
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
insert image - JSP-Servlet
insert image  hi friends i am mahesh i am trying to insert image into oracle database using JSP but i am not geting so please friends send me the code for inserting image into database using JSP   Hi Friend, Try
display image using jsp
display image using jsp  display image using jsp and phonegap on emulator of eclipse   Here is a simple jsp code that displays an image on browser. <%@ page import="java.io.*" %> <%@page contentType="image/gif
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
download image using url in jsp
download image using url in jsp  how to download image using url in jsp
how to use image tag in jsp
how to use image tag in jsp  How to use image tag in JSP
Image upload file - JSP-Servlet
Image upload file  I want a code for image upload jsp or servlet.  Hi friend, For image upload jsp or servlet visit to : http://www.roseindia.net/jsp/file_upload/employee_upload_profile_image.shtml http
Dynamic table data to Excel in JSP
Dynamic table data to Excel in JSP   Iam trying to export dynamic data to excel . But it is displaying only static data .Kindly help viewtrial.jsp <%@page import="java.sql.*"%> function des_setEnable
Image - JSP-Servlet
Image  Hi Experts, I need your help (Source Code)on how I can send and retrieve image to/from Microsoft Sql 2000 database (NOT MYSQL) using java servlet or Jsp and html form. Please the output should be displayed in an html form
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in image tag but i am...(); response.setContentType("image/jpg"); response.getOutputStream().write(rb,0,len
upload image using JSP Hibernate
upload image using JSP Hibernate  sir, I want to take image from user and save to database(MYSQL) using Hibernate and JSP Thanks in advance
Uploading image using jsp
Uploading image using jsp  how to upload image using jsp. Already i tried, But that image file does not read. It returns only -1 without reading...; Here is a jsp code that upload image and display it on the browser. 1
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in tag but i am...(); response.setContentType("image/jpg"); response.getOutputStream().write(rb,0,len
JSP:select image for db and display in image tag
JSP:select image for db and display in image tag  Hi, i am new to this forum. My query is that, i am trying to display image in tag but i am...(); response.setContentType("image/jpg"); response.getOutputStream().write(rb,0,len
Jsp Image Display
Jsp Image Display  Hi,i need to display image in a Box like in profile photo,when i click on the browse button,file gets open and the selected image... to save it in a database....Kindly post JSP codes..Its Urgent, I m very thankful t
retrieving image files - JSP-Servlet
retrieving image files  How to retrieve multiple images at a time from mysql database using JSP

Ads