hey i have a problem in obtaining the path of the image which i have to upload using jspservlet...
actually the problem is ...i have used getParameter to get the image path and then using the image i store the image in database ...but getParameter is not returning me the complete path of the image instead it returns only the image name...
here is my code please check it as soon as possible ....eagerly wating for reply:
my index.jsp page
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
// create a file object for image by specifying full path of image as parameter.
File image = new File(imageUrl);
//String ab = image.getCanonicalPath();
FileInputStream fis = new FileInputStream(image);
psmnt = connection.prepareStatement("insert into pic values(?,?)");
psmnt.setBinaryStream (2, (InputStream)fis, (int)(image.length()));
/* executeUpdate() method execute specified sql query. Here this query
insert data and image from specified address. */
int s = psmnt.executeUpdate();
out.println("Uploaded successfully !");
out.println("unsucessfull to upload image.");
catch (Exception ex)
out.println("Found some error : "+ex);
A few things to help you make the most of the Ranch as resource:
First, please use real words when posting to the forums. Abbreviations such as "d" in place of "the" only serve to make your posts more difficult to read and less likely to generate useful responses. Please click this link ⇒ UseRealWords for more information.
I have fixed the subject for you so it is understandable.
Secondly, please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.
Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
1.) Your form does not define correct enctype (enctype="multipart/form-data") so the file is never even sent to server.
2.) You seem to think that server stores the file locally (i.e. writes it to disk). How do you know that? What server are you using?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com