
photo gallery Iam uploading images in the serverusing uploading program, now i need to display all the images from the folder and i want to display it on JSP. like facebook and orkut did.. Please suggest me....
How to store the link of a image in a database. it is neccessary..... I am using a link "Photo Gallery" to show the image.
Pls reply ASAP...

1)images.jsp:
<%@ page import="java.sql.*,java.io.*,java.util.*" %>
<HTML>
<table border="1">
<%
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 * from image";
ResultSet rs = stmt.executeQuery(strQuery);
while(rs.next()){
%>
<tr>
<td>
<img src="image.jsp?imgid=<%=rs.getInt(1)%>" width="50" height="50">
</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();
}
%>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.