Hello,
I have created below program and program is throwing FileNotFound exception when I pressed the submit button. The problem is coming due to JSP page is not able to find complete path of image. I have debug the JSP program and found that HTML form pass only image name without path that's why problem is coming. Can anyone resolve this problem.
################## SQL Query ######################################
CREATE TABLE IMAGEMAIN(ID INTEGER,IMAGE BLOB) ;
################## HTML Form ######################
<form name="frm" method="post" action="index.jsp">
<input type="text" name="hint">
<input type="file" name="user_file">
<input type="submit">
################### JSP PAGE ########################
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Connection loaded");
Connection con = DriverManager.getConnection("jdbc:odbc:project","image","image");
System.out.println("Connection created");
String ll=request.getParameter("user_file");
String lo=request.getParameter("hint");
File imgfile = new File(ll);
FileInputStream fin = new FileInputStream(imgfile);
PreparedStatement pre = con.prepareStatement("insert into IMAGEMAIN (id,image) values(?,?)");
pre.setString(1,lo);
pre.setBinaryStream(2,fin,(int)imgfile.length());
pre.executeUpdate();
pre.close();
}
catch(Exception E)
{
out.println("the eror is "+ E);
}