Hello Experts pls i want get all the form data for id card along with the passport image when correct id corresponding to the database row is inputed. the code only retrieves other form data but can't get the image.
--------------recovery.jsp---------
<HTML>
<HEAD>
<TITLE>Database Lookup</TITLE>
</HEAD>
<BODY>
<FORM ACTION="recover1.jsp" METHOD="POST"><fieldset><legend>
<font size="5" color="green">
Please Enter id to Search </font></legend>
<BR>
<INPUT TYPE="TEXT" NAME="id" size="40">
<BR>
<INPUT TYPE="RESET" value="clear all" size="40"><INPUT TYPE="SUBMIT" value="Search Account"></fieldset>
</center>
</BODY>
<HTML>
<%@ page import="java.sql.*" %>
<% Class.forName("com.mysql.jdbc.Driver"); %>
<HTML>
<HEAD>
<TITLE>Fetching Data From a Database</TITLE>
</HEAD>
<BODY>
<%
Connection connection = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/student", "root", "root");
Statement statement = connection.createStatement();
String id = request.getParameter("id");
ResultSet resultset =
statement.executeQuery("select * from job where id = '" + id + "'");
if(!resultset.next()) {
out.println("<font size=3 color=red>Sorry,we can't find your informations.</font>");
} else {
%>
<TABLE BORDER="1" bordercolor=green>
<TR>
<TH>
<font size="3" color="green">ID:</font></TH>
<TH>
<font size="3" color="green">USERNAME:</font></TH>
<TH>
<font size="3" color="green">PICTURE:</font></TH>
</TR>
<TR>
<TD> <%= resultset.getString(1) %> </TD>
<TD> <%= resultset.getString(2) %> </TD>
<TD> <%= resultset.getBlob(3) %> </TD>
</TR>
</TABLE>
<BR>
<%
}
%>
<BODY>
</BODY>
</HTML>
I said ok let me develop servlet or another jsp to retrive the image along with other id card data so i did this
<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.io.*"%>
<%
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection con=null;
ResultSet rs=null;
Statement stmt=null;
String id = request.getParameter("id");
try
{
con=DriverManager.getConnection("jdbc:mysql://localhost/student?user=root&password=root");
stmt=con.createStatement();
}
catch(Exception e)
{
out.println(e.getMessage());
}
rs=stmt.executeQuery("select * from new ");
rs.next();
response.setHeader("expires", "0");
response.setContentType("image/jpeg");
out.clear();
OutputStream os = response.getOutputStream();
os.write(rs.getBytes("fred3"));
out.flush();
%>
and for the display i used
<a href="shango3.jsp?id=1<<%=resultset.getInt(1)%>">
<img src="shango3.jsp?id=1<<%=resultset.getInt(1)%>" width="100" height="100">
but i successed in getting the passport image and the id card data of the first row when id 1 is inputed but when i entered id 2 i can't get information at all unless i go to my code and set id=2. my servelet is still doing the same thing.
this code has stressed me for 2 months now.
Now my plea is this,is there any way you can help me even if there is any site where i can see example on how to get passport image along with other form data when correct id is inputed may be using jsp or even jsp/servlet.
thanks for your patience.