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.

Recommended Answers

All 7 Replies

within a few pages, this code will become almost impossible to read/maintain.
you could familiarize yourself with the use of servlets, and use those to perform all the tasks you want to be done.

when reading further on the use of requests en responses, you'll figure out how to pass the data from one 'page' to another.

thank u for your response .I have tried it using servlet but am still having the same problem.the point is these ,is there any site you know where i can get an articles or tutorials that can help me achieve this goal.
thanks

Check this

Thank you i have already known these but it has no link with what am trying to do b/c no blob data retrival along with other database records where there thus may be i will send you another servlet i develope with some description so that u can assist me.
I am glad for ur help so far.

write good English first. Once you've managed that use that knowledge to read some good books and tutorials.
After that, you might be able to write decent code after some practice.

Thank you i have already known these but it has no link with what am trying to do b/c no blob data retrival along with other database records where there thus may be i will send you another servlet i develope with some description so that u can assist me.
I am glad for ur help so far.

The above tutorial is exactly what you need because you are going about database connectivity in wrong way. Adding blob data type to it is simple matter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.