how to display multiple images on browser

how to display multiple images on browser

i want to display multiple images on brower including string values from sql database using jsp.

View Answers

December 21, 2010 at 3:13 PM

Hi Friend,

Try the following code:

1)images.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<HTML>
 <table>
   <%
  try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
    Statement stmt=con.createStatement();
    String strQuery = "select id from image";
    ResultSet rs = stmt.executeQuery(strQuery);
    while(rs.next()){
       %>
      <tr>
      <td align="center">
<img src="image.jsp?imgid=<%=rs.getInt(1)%>" width="100" height="100">
</a></td>
      </tr>
      <%
    }
    rs.close();
    con.close();
    stmt.close();
  }
  catch(Exception e)
  {
    e.getMessage();
  }
  %>
 </table>
</HTML>

2)image.jsp:

<%@ page import="java.sql.*,java.io.*,java.util.*" %> 
<%
  int id =  Integer.parseInt(request.getParameter("imgid"));
  try{      
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");      
    Statement st=con.createStatement();
    String strQuery = "select images from image where id="+id;
    ResultSet rs = st.executeQuery(strQuery);

    String imgLen="";
    if(rs.next()){
      imgLen = rs.getString(1);
       }  
    rs = st.executeQuery(strQuery);
    if(rs.next()){
      int len = imgLen.length();
      byte [] rb = new byte[len];
      InputStream readImg = rs.getBinaryStream(1);
      int index=readImg.read(rb, 0, len);  
      st.close();
      response.reset();
      response.getOutputStream().write(rb,0,len); 
      response.getOutputStream().flush();        
    }
  }
  catch (Exception e){
    e.printStackTrace();
  }
%>

Thanks


December 21, 2010 at 9:04 PM

hi friend

     my project aim is  to display all the data including images at a time on the browser from the database(sql) at a  time .so is there any change to get the all the images and sno,imagename , etc(table fields:sno,sname,image,description).plz send complete code revert to this mail. i am very thankful to u as early as possible fnd.

thanks ®ards M Jagan









Related Tutorials/Questions & Answers:
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
how to display multiple images on browser
how to display multiple images on browser  i want to display multiple images on brower including string values from sql database using jsp
Advertisements
How to display multiple images in jsp
How to display multiple images in jsp  <%@ page import="java.io....()); System.out.println("st-7 "+brr); // display the image response.setContentType("image... "); } } catch (Exception e) { out.println("Unable To Display image"); out.println
Display Multiple Images in jscrollpane using Java Jpanel
Display Multiple Images in jscrollpane using Java Jpanel  Browse and Display multiple images in vertical view of java jscrollpane using jpanel
display multiple images from postgres database in jframe
display multiple images from postgres database in jframe  i just want to display multiple images on jframe by firing a query on postgres database
how to display pdf file on browser
how to display pdf file on browser   In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by iframe tag can anyone
how to scroll multiple images using on Click in Android
how to scroll multiple images using on Click in Android  I am new... there is requirement like multiple image scrolling dynamically. But unfortunately i am unable to scroll multiple images. But i am able to scroll single image. plz let me know
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp... to upload the multiple images in struts Total images storing folder in project...;COLLEGE INFORMATION :</legend> <pre> Gallery Images: <input type
how to display the excel file in the web browser.
how to display the excel file in the web browser.  > %@ page import="java.io.InputStream" > %> <%@ page > import="org.apache.poi.xssf.usermodel.XSSFSheet"%> > <%@ page > import
how to display csv file directly in IE browser .
how to display csv file directly in IE browser .  here is my code : public String download(){ if(log.isDebugEnabled()){ log.info("Entered for downloading: "); } FacesContext facesContext
How to display images in jsp ffrom sqlserver2000 - JSP-Servlet
How to display images in jsp ffrom sqlserver2000   These code u sent is till not displaying the image in jsp from sqlserver2000. what table has to create under database? what are the fields of table to create
how insert multiple images in mysql database with use of struts 1.3.8 or java method, with single bean,or using array
how insert multiple images in mysql database with use of struts 1.3.8 or java... ,with struts 1.3.8 and i want to insert multiple images in mysql database ,with use of struts 1.3.8 ,or with the help of Array methods ,like google multiple
pint multiple images from blob database
pint multiple images from blob database  How to display multiple images using blob from mysql database. The program code is as below: <TABLE cellpadding="15" border="1" style="background-color: #ffffcc;"> <
Display PDF in browser - Struts
Display PDF in browser  Hi, I am trying to display the pdf file in the browser using struts 2. Here i am using iText for pdf generation... ON Browser")); document.close(); HttpServletResponse response
Problem with display of images in applets - Applet
Problem with display of images in applets  Hi all, When I run this program, the appletviewer window is showing no output (i.e. no image). I'm..., this); } } --------------------------------------- Display image in Java Applet
display records with images problem - JSP-Servlet
display records with images problem  hello, i am developing HR application whereby i want to display employee records and their pictures on web..., Display images from database to visit ... http://www.roseindia.net/jsp
How send different files to browser at same time ..example(pdf&html) want display in same request using servlet
How send different files to browser at same time ..example(pdf&html) want display in same request using servlet  package com.readfiles; import...); } } }![alt text][1] [1]: http://How send different files to browser
all sequences to create jdbc and how can i use jtable to display a single columns or multiple columns
all sequences to create jdbc and how can i use jtable to display a single columns or multiple columns  i am 3rd year cs student in ethiopia. i have a view in my database schema so how can i create a jtable to look the view result
how to display image with listview
how to display image with listview  How can i display the list view with the related images from database
Animating Images in Java Application
Animating Images in Java Application       This section shows you how to create an animation with multiple images. You can see how animation has been implemented in the following
code to display images using 2d array - Swing AWT
code to display images using 2d array  HI !! I have an image file... to display this using java code. I am relatively new to coding such requirements. Can anyone please tell me how to go about it ? Explanation of the code
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to display?
how to display?  How to write a select query for displaying data where i have author as multivalued attribute
how to space images in html code
how to space images in html code  how to space images in html code
display multiple image file or pdf file in multiple column of a row from server or database
display multiple image file or pdf file in multiple column of a row from server... want to display that file to the user page but I want to display that file in a particular format i.e I have to display more than one files in multiple columns
java program to read multiple files from a directory and display them on a jframe
java program to read multiple files from a directory and display them on a jframe  hi guys i want to write a java program that will read all files in a directory and display them one by on on a jframe on jpanel with specific key
how to dispaly pdf file on browser
how to dispaly pdf file on browser  In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by tag can anyone give me
how to display?
how to display?  I have to write a code for searcing books in library and i have written but it is not displaying the result.I don't know where i have gone wrong.Also i want to know if there is any better idea then this and what
browser
browser  how to make a browser
How to get browser time zone?
How to get browser time zone?  How to get browser Time Zone and browser date using java concept
I need to launch multiple instances of IE browser from one windows M/C on the another windows M/C
I need to launch multiple instances of IE browser from one windows M/C on the another windows M/C  multiple instances of IE browser from one windows M/C on the another windows M/C
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
how to upload and download images in java?
how to upload and download images in java?  what is the code for uploading and downloading images in java? how do I make a photo gallery through JSP....   Upload and Download images: 1)page.jsp: <%@ page language="java
how to disable browser back button
how to disable browser back button  Am doing a web application in that how to disable browser back button using java script
Moving The Images
Moving The Images  How to moving multiple images in one frame using swings
how to make multiple rectangles
how to make multiple rectangles  I,m a beginner , m sorry if the question is really simple i have an array list.I want to print the contents of the array list in rectangles. as in each element should be in different rectangles

Ads