Insertion of image in mysql using jsp HTTP Status 404 not found

Ashwin Karki

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());
                        }
                        %>

*
PacMan

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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

JSP/JDBC: HTTP Status 404 - Not Found

HTTP Status 404 - Not Found - Servlet and JSP

HTTP Status 404 - Servlet not found

Servlet: HTTP Status 404 - Not Found

The webpage cannot be found - HTTP 404 JSP page

Maven web project HTTP Status [404] – [Not Found]

Eclipse & Tomcat Error: HTTP Status 404 – Not Found:

HTTP 404 status code (Not Found) shown as 302

HTTP Status 404 – Not Found Spring Boot

HTTP Status 404 – Not Found tomcat spring

HTTP Status [404] ? [Not Found] for /login in spring security

HTTP Status 404 – Not Found on Tomcat server

HTTP Status 404 – Not Found: for controller - no view resolvers found in Idea

http status 404 hello.jsp (apache tomcat 6)

How to redirect "HTTP Status 404 – Not Found" to an error information page in tomcat?

Spring Mvc get HTTP Status [404] – [Not Found] after the submission

Spring Mvc App get - HTTP Status [404] – [Not Found]

HTTP Status [404] ? [Not Found] (The origin server did not find a current representatio)

HTTP Status 404 Not Found For Jersey REST application with Eclipse and Payara server

Why am I getting HTTP Status 404 - Not Found?

Status: 404-Not found

HTTP Status 404 - /LoginAuth

HTTP Status 404 -

Whitelabel Error Page There was an unexpected error (type=Not Found, status=404). /WEB-INF/views/home.jsp

Image source is not found in my JSP page. Getting 404 page not found in browser console

HTTP Status 500: When using form:input tag in jsp

Upload image to mysql using jsp,servlet

HTTP status 404 not found after requesting http://localhost:4080/testAPI/rest/hello

Http 404 Not Found