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



Home Answers Viewqa JSP-Servlet displaying both image and records problem in jsp and servlet

Have Programming Question? Ask it here!
 
 
 


dipo
displaying both image and records problem in jsp and servlet
3 Answer(s)      5 years and 7 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

September 18, 2008 at 5:15 PM


Hi friend,


Code to help solve the problem.


<%@ page import="java.sql.*,java.io.*,java.util.*" %>
<HTML>
<HEAD>
<TITLE>Download Images</TITLE>
</HEAD>

<BODY>
<br><br>
<table align="center" border=0 width="200px">
<tr>
<td colspan=2 align="center"><b>Employee Record</b></td>
</tr>
<tr><td colspan=2>&nbsp;</td></tr>
<%

String connectionURL = "jdbc:mysql://localhost:3306/userdetails";;
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection(connectionURL,"root","root");
Statement stmt=con.createStatement();
String strQuery = "select id from imageupload";
ResultSet rs = stmt.executeQuery(strQuery);
int sno=0;
while(rs.next())
{
sno++;
%>
<tr style="background-color:#efefef;">
<td><b><%=sno%></b></td>
<td><b><%=rs.getString("firstname")%></b></td>
<td><b><%=rs.getString("lastname")%></b></td>
<td><b><%=rs.getInt("empid")%></b></td>
<td><b><%=rs.getString("department")%></b></td>
<td><b><%=rs.getInt("salary")%></b></td>
<td><b><%=rs.getString("job_title")%></b></td>
<td align="center">
<a href="image.jsp?imgid=<%=rs.getInt(1)%>">
<img src="image.jsp?imgid=<%=rs.getInt(1)%>" width="50" height="50">
</a></td>
</tr>
<%
}
rs.close();
con.close();
stmt.close();
}
catch(Exception e)
{
e.getMessage();
}
%>
</table>
</BODY>
</HTML>


September 18, 2008 at 5:27 PM


"image.jsp"

<%@ page import="java.sql.*,java.io.*,java.util.*" %>
<%

String connectionURL = "jdbc:mysql://localhost:3306/userdetails";;
if(request.getParameter("imgid")!=null && request.getParameter("imgid")!="")
{
int id = Integer.parseInt(request.getParameter("imgid"));

String filename = "image"+id+".jpg";
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection(connectionURL,"root","root");
Statement st1=con.createStatement();
String strQuery = "select imagefile from imageupload where id="+id;

ResultSet rs1 = st1.executeQuery(strQuery);

String imgLen="";
if(rs1.next()){
imgLen = rs1.getString(1);
}
rs1 = st1.executeQuery(strQuery);
if(rs1.next()){
int len = imgLen.length();
byte [] rb = new byte[len];
InputStream readImg = rs1.getBinaryStream(1);
int index=readImg.read(rb, 0, len);
st1.close();
response.reset();
response.setContentType("image/jpg");
response.setHeader("Content-disposition","attachment; filename=" +filename);
response.getOutputStream().write(rb,0,len);
response.getOutputStream().flush();
}
}
catch (Exception e){
e.printStackTrace();
}
}
%>


Thanks



November 2, 2012 at 12:45 AM


A tons of thanks to u bro it worked. u saved me from HEll:-)



Related Tutorials/Questions & Answers:
displaying both image and records problem in jsp and servlet - JSP-Servlet
displaying both image and records problem in jsp and servlet  hello... the application to display more than one employee records and their pictures. e.g. say i'm having records like: firstname, lastname, empid, department, salary, job_title
displaying images and records problem - JSP-Servlet
displaying images and records problem  hi, Thanks for your reply... display any record and image. I posted my question and since then no replay. Please, kindly help me to solve the problem urgently. Or in any other way to do
Advertisements
displaying employee records and their images problem - JSP-Servlet
displaying employee records and their images problem  hi, Thanks for your reply to my question. The code you sent to me yesterday was not working. it doesn't display any record and image. Please, help me out urgent
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 records with images problem - JSP-Servlet
with a unique id. Also i wrote i jsp that link to servlet in order to display...display records with images problem  hello, i am developing HR application whereby i want to display employee records and their pictures on web
Problem displaying resultset in jsp(no frameworks used) - JSP-Servlet
Problem displaying resultset in jsp(no frameworks used)  Problem... if the resultset return 25 rows, these 25 records are to be displayed in my jsp. My problem area: a) How to display the records within JSP from request>arraylist>
How to Insert image and data both together in database in JSP/Servlet ?
How to Insert image and data both together in database in JSP/Servlet ?  //form.jsp <%@ page language="java" %> <HTML> <HEAD>... image String nn=request.getParameter("name"); String cc=request.getParameter
Image problem Urgent - JSP-Servlet
Image problem Urgent  Respected Sir/madam, I am R.Ragavendran.. Actually I got your coding.. But This code is not enabling the user to click and change the image.. I request you to remember the code which you have
Displaying image when clicked on URL in jsp - JSP-Servlet
Displaying image when clicked on URL in jsp  Hi, I am using... in displaying the image from the folder. Regards, Anish... For Screenshot : abc.jpg here abc.jpg is a url and when clicked would show me an image
Data displaying with limited records in jsp
Data displaying with limited records in jsp  How to display table with limited 10 records , after clicking next button another 10 records from database upto last record please help me
Retrieving newly inserted records and displaying in jsp forever
Retrieving newly inserted records and displaying in jsp forever  Sir, here is my requirement, First i have to retrieve newly added 10 records from... those records in the jsp. If the session-duration exceeds 10 minutes for any
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
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
Displaying Rows - JSP-Servlet
Displaying Rows  Hi, I need your support on how to display data from... servlet or jsp  Hi friend, This is form code, display data in servlet Display Data In Servlet
Name Displaying - JSP-Servlet
vijayababu.m@cybermateinfotek.com  Hi AJAX and Servlet var
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I...; In between the <div></div> I have to display the records. I am displaying... it is not right way. I have written a following servlet to get the records from
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... me abt it, here is code for both insert and retrieve image form database and its
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... me abt it, here is code for both insert and retrieve image form database and its
Servlet Problem - JSP-Servlet
Servlet Problem  Hii I am Ajay . I am makin g a project in java... with that image. But when ever I try to dispaly it. Either the image gets displayed r textual info but not the both. Can u plzz help me
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 this problem. Thanks & Regards, Suresh   Jsp Display Image <
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
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
JSP Problem - JSP-Servlet
JSP Problem  Hi, I have problem,this is my senario I have one jsp,this jsp having the 3 fields.let me take 3fields userName,emailAddress... and insert in to the data base(i mean 5 records should be saved when ever i click
How to check no records - JSP-Servlet
How to check no records  Hi all, I am developing an onlineshopping project, in that how i have 2 check no records. I saw an answer, but is for finding not null only... ie, if(rs!=null) But i need the null checking
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 ,Servlet Problem - JSP-Servlet
Jsp ,Servlet Problem  hi, m new to jsp n Servlet. i really find ur... with oracle. it worked wonders. now i m starting jsp n servlet learning.. pls... to execute a servlet code on tomcat server... Thanking u... Santosh  
Upload and display image and text records using JSP and Oracle
Upload and display image and text records using JSP and Oracle  Hi all, I'm using JSP and Oracle 10g. I could retrieve and display records... the image ( uploaded by the user) and retrieve it along with the other records. Please
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
jsp problem - JSP-Servlet
jsp problem  hi, i am working on a project of developing a shopping cart for online book store.can it be done using jsp?if yes, can u please help me doing so?  Hi Friend, Please visit the following link: http
printing records from jsp - JSP-Servlet
printing records from jsp  Hi Plz tell me how to printing out pages..., For paging in Jsp visit to : http://www.roseindia.net/jsp/paging.shtml http://www.roseindia.net/jsp/bank.shtml Thanks
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
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
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 displaying in java
image displaying in java  how to display an image by using load image button in applet viewer
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
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
logout problem.. - JSP-Servlet
done in the code i have used session object in project's servlet and jsp...logout problem..  hi... first of all thanks for ur... but their is some problem with the the logout,i m not able to logout when
problem in programming - JSP-Servlet
problem in programming  Hi! I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
Java Servlet Problem - JSP-Servlet
Java Servlet Problem  I have a servlet class that implemets..., but in the attributeReplaced() method, i want to perform a redirect to another servlet... method. Please help!!  Hi friend, Please explain problem
tomcat problem - JSP-Servlet
with both j2sdk 1.4.2_07 and 1.5 version with tomcat 5.0.25 v. For both versions... perfectly. Kindly let me know what is the problem at an earliest. Thanking... found your problem.. http://www.roseindia.net/web-application-server/tomcat
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
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
arraylist problem - JSP-Servlet
my code once again only in which i m facing the problem. /* * To change... { /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request * @param response servlet response
Uploading an image - JSP-Servlet
Uploading an image  I am doing a jsp project. In this uploading an image is a part. For that i had done a coding for uploading. But, it will not check for file size. File path getting had done by a different jsp page
Servlet Problem proceed - JSP-Servlet
Servlet Problem proceed  Thank you fro your reply. But I couldnt find any serious error.Please see this. User is the package classes/User... problem then read more details. http://www.roseindia.net/servlets
logout problem?? - JSP-Servlet
logout problem??  sir, the logout code which u have send is not the proper solution coz,by using this code the browser get closed which shuold.../Logout.shtml http://www.roseindia.net/jsp/loginstatus.shtml Thanks
Array problem - JSP-Servlet
number of records.. I need to select the radio button.. After selecting..... Bur my problem is that if the pop up window contains only 1 record
pagination problem - JSP-Servlet
using servlets in that i called a these methods,to call this servlet i created a html file i wrote one form to call this servlet. In this servlet i used doget...(),my problem is that where i have to put & how to do pagination? my code
pagination problem - JSP-Servlet
using servlets in that i called a these methods,to call this servlet i created a html file i wrote one form to call this servlet. In this servlet i used doget...(),my problem is that where i have to put & how to do pagination? my code
coding problem - JSP-Servlet
coding problem  dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess) .and after that option being selected for that the record from the databse should
 

 

 

DMCA.com