Upload Image and save in database using jsp-servlet mvc

Ads
 

Upload Image and save in database using jsp-servlet mvc

Here is my code..
 In jsp ...

    <form name=frm method="post" action="Device">
    <table>
    <tr><TD ><B>Upload Image</B></TD>
    <td><input type="file" name="Image" size="20" value=""></TD>
    </tr>
    <tr>
    <td><input type="submit" height="30" width="62"> </td>
    </tr>
    </form>

<form name=frm method="post" action="Device">
<table>
<tr><TD ><B>Upload Image</B></TD>
<td><input type="file" name="Image" size="20" value=""></TD>
</tr>
<tr>
<td><input type="submit" height="30" width="62"> </td>
</tr>

In servlet...

    try
            {
                String strpath=request.getParameter("Image");
                String filepath=strpath.substring(strpath.lastIndexOf("\\")+1);
                File imgfile = new File(strpath);

                FileInputStream fin = new FileInputStream(imgfile);

            Connection connection=null;
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
            PreparedStatement pre = connection.prepareStatement("insert into uploadimage(image,image_name,image_length) values(?,?,?)");

            pre.setBinaryStream(1,fin,(int)imgfile.length());
            pre.setString(2,filepath);
            pre.setLong(3,imgfile.length());
            pre.executeUpdate();
            pre.close();
            String L_url1=response.encodeRedirectURL("Device.jsp");
            response.sendRedirect(L_url1);

            }
            catch(Exception ex){
            System.out.println("Exception in InsertImage : "+ex.getMessage());
            }
        }

but throws exception

    (The system cannot find the file specified)

How to rectify..
View Answers

Ads









Related Tutorials/Questions & Answers:
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device"> <table> <tr><TD ><B>Upload Image</B><
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device">...; In servlet... try { String strpath=request.getParameter("Image
Advertisements
Image upload in mysql database using jsp servlet
Image upload in mysql database using jsp servlet  Hello, I need code to insert image in mysql database, I have seen the code which is already in your portal but it is not inserting image into database it save in the folder
save multiple records into database using jsp/servlet mvc
save multiple records into database using jsp/servlet mvc  hai, this is my jsp where i have enter multiple username and password and save it to database in single hit user.jsp <form action="UserServlet" method="post
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
How to upload files to server using JSP/Servlet?
How to upload files to server using JSP/Servlet?  How to upload files to server using JSP/Servlet
Jsp using mvc - JSP-Servlet
Jsp using mvc  hi I have written using mvc2 architecture, i have written logic in java ,i want to print a message on the form stating the the values... closely together. Read MVC 2 Pattern in Struts2 in details and visit
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file... like Emp name, Emp id, city, address and one employee profile image(upload
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database...){e.printStackTrace();} } %> 3)For oracle database, use BLOB datatype for image
edit database using jsp and servlet
edit database using jsp and servlet  I am creating a website using jsp and servlets that is used to view houses from a database. I want to be able... information from the database in the textboxes. Please help me to display
How to create file and save it into user defined path using jsp/servlet?
How to create file and save it into user defined path using jsp/servlet?  Hi.. Onclick event I have created one file.When file will create it should asked where to save file(like browse option
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
How to browse excel file and stored the contents into the database using jsp/servlet?
How to browse excel file and stored the contents into the database using jsp/servlet?  Hi.. I want to browse excel file and stored the file data into the My-sql database using jsp/servlet
fetch record from oracle database using jsp-servlet?
fetch record from oracle database using jsp-servlet?  how can i fetch data from oracle database by using jsp-servlet. i'm using eclipse, tomcat server and oracle database and creating jsp pages and also using servlet
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
upload image using JSP Hibernate
upload image using JSP Hibernate  sir, I want to take image from user and save to database(MYSQL) using Hibernate and JSP Thanks in advance
upload image to database
upload image to database  i am try to upload image to MySql database using netbeans. when jsp execute it return no error. but also data does inserted in database. i am using blob datatype and preopared statement
How display a image on servlet from file upload - JSP-Servlet
How display a image on servlet from file upload  Dear Sir, My issue is: How display a image on servlet from file upload I receive your answer today... upload page Employee Image
How to save run time created text-file on a disk using jsp/servlet?
How to save run time created text-file on a disk using jsp/servlet?  I have a JSP page with save button.In that I created the file(e.g a.txt) at run-time,when I click on the save button,it will ask where to save the file
How to Insert image and data both together in database in JSP/Servlet ?
How to Insert image and data both together in database in JSP/Servlet ? ...;<TITLE>Display file upload form to the user</TITLE></HEAD> <... colspan="2" align="center"><B>UPLOAD THE FILE</B><center><
How to insert and retreive an image in mysql database using spring mvc framework???
How to insert and retreive an image in mysql database using spring mvc... for handling all application requests --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>
how to upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
fetch and insert multiple rows into mysql database using jsp servlet
fetch and insert multiple rows into mysql database using jsp servlet  ... jsp form and want inserting it into my mysql database table. but i am having a problem to insert multiple rows into database using a single insert query
Uploading an image into the table - JSP-Servlet
to the specified database. */ psmnt = connection.prepareStatement ("insert into save_image...Uploading an image into the table  how to upload an image... { System.out.println("unsucessfull to upload image."); } } // catch if found
image display - JSP-Servlet
image display  how to display image that store in mysql database... column have BLOB datatype....  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/retrieve-image.shtml Thanks
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
i want to save image on server folder. and i want to save URL of this folder and name of image in database
i want to save image on server folder. and i want to save URL of this folder and name of image in database  hi i want to save image on server folder. and i want to save URL of this folder and name of image in database.on click
Multiple image upload using JSP
Multiple image upload using JSP  I have written a code to upload the multiple images using jsp, but when I execute this code, it throws Corrupt form... = getServletContext().getRealPath("/") + > File.separator + > UPLOAD_DIRECTORY;/*save
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
jsp page authentication panel using jsp/servlet?
jsp page authentication panel using jsp/servlet?  I have 10 jsp jsp forms and 7 users and i want to grant variour permission like edit,delete and save for users dynamically on forms.So please refer me code

Ads