Reputation: 385
I get some error as 404 not found error plz help me. Insertion of image in mysql using jsp HTTP Status 404 not found.i m trying to insert image in mysql database and i have used mysql jdbc driver.
In index.jsp
<%--
Document : index
Created on : 23-Jan-2017, 11:51:34
Author : AshwinKArki
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name="f1" method="post" action="main">
Select file:<input type="file" name="file1" >
<input type="submit" value="insert" />
</form>
</body>
</html>
in Main.jsp : another page
<%@page import="java.sql.*" %>
<%@page import="java.io.*" %>
<%
String file2=request.getParameter("file1");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost/storefile");
String sql="INSERT INTO tbl_image VALUES (?)";
PreparedStatement stmt=conn.prepareStatement(sql);
stmt.setString(1,file2);
stmt.executeUpdate();
out.print("Suucesfull");
stmt.close();
conn.close();
}catch(Exception e){
out.print(e.getMessage());
}
%>
*
Upvotes: 1
Views: 61
Reputation: 1358
you are not forwarding to the right action , since your action is a jsp file so you should set the extension too , not like servlet when you set just the name of the file , so there must be : action="main.jsp"
and not action="main"
<form name="f1" method="post" action="main.jsp">
Select file:<input type="file" name="file1" >
<input type="submit" value="insert" />
</form>
Upvotes: 1