i am inserting an image into database but it is showing relative path not absolute path

i am inserting an image into database but it is showing relative path not absolute path

hi my first page.........

<html>
<head>
<title>Image</title>
</head>
<body bgcolor="lavender"></p>

<form action="addimage.jsp">
Enter your name:<input type="text" name="sname"><br><br>
Upload photo:<input type="file" size="50" name="url"><br><br>
Father name:<input type="text" name="fname"><br><br>
Age:<input type="text" name="age"><br><br>
Username:<input type="text" name="usn"><br><br>
Password<input type="password" name="pasws"><br><br>
Qualification:<input type="text" name="qal"><br><br>
Gender:<input type="text" name="gen"><br><br>
Phone number:<input type="text" name="pno"><br><br>
<input type="submit" value="add">
</form>

</body>
</html>

then addimage.jsp

&lt;%@ page import="java.io.<em>,java.sql.</em>" %>
<html>
<head><title>Imageadd</title>
</head>
<body>
&lt;%
    try
    {
    String name=request.getParameter("sname");
    String url=request.getParameter("url");
    System.out.println(url);
    String fname=request.getParameter("fname");
    String usname=request.getParameter("usn");
    String pass=request.getParameter("pasws");
    String uage=request.getParameter("age");
    String uqal=request.getParameter("qal");
    String ugen=request.getParameter("gen");
    String upno=request.getParameter("pno");
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:scott/tiger@//localhost:1521/XE","scott","tiger");
    PreparedStatement pst = con.prepareStatement("insert into errortab values(?,?,?,?,?,?)");</p>

pst.setString(1,name);
pst.setString(2,fname);
pst.setString(3,uage);
pst.setString(4,uqal);
pst.setString(5,ugen);
pst.setString(6,upno);
pst.executeUpdate();
pst.close();

PreparedStatement ps = con.prepareStatement("insert into dlogin values(?,?,?)");

File file = new File(url);
    FileInputStream fs = new FileInputStream(file);
    ps.setString(1,usname);
ps.setString(2,pass);
ps.setBinaryStream(3,fs,fs.available());
    ps.executeUpdate();
out.println("thank u for registration");
out.println("ur values are inserted into database");
}
catch(Exception e)
{
System.out.println(e);
}

%>
</body>
</html>

when i compiled it i got error "java.io.filenotfoundexception" please go through it and help me....

thanks in advance

View Answers

May 22, 2012 at 10:44 AM

<%@page import="java.sql.,java.io."%> <%

String upload=request.getParameter("upload"); File file = new File("upload"); String str=file.getAbsolutePath();

%>

<%=str%>









Related Tutorials/Questions & Answers:
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path not absolute path   hi my first page......... Image Enter your name... into database"); } catch(Exception e) { System.out.println(e); } %> when i
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path not absolute path   hi my first page......... Image Enter your name... into database"); } catch(Exception e) { System.out.println(e); } %> when i
Advertisements
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path not absolute path   hi my first page......... <html> <head>..."); out.println("ur values are inserted into database"); } catch(Exception e
inserting an path of an image in database - JDBC
inserting an path of an image in database  hello kindly help related... time its full path should be inserted in the database(MS Sql 2000).. I m able to save it in folder..but can you plz tell me how an the full path of image can
absolute path in php - PHP
absolute path in php  how to get absolute path in php
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m... it physical path will get saved in a database.. I have table created... path.. and also how to retrive that image path and show that picture in a small
how to get the image path when inserting the image into pdf file in jsp - JSP-Servlet
how to get the image path when inserting the image into pdf file in jsp  Hi Friend, my image path;C:/images/photo.jpg. i am getting the below...: Thanks  I am getting the same problem. error is coming
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
how to get the image path when inserting the image into pdf file in jsp - JSP-Servlet
how to get the image path when inserting the image into pdf file in jsp  I am using the below code but i am getting the error at .getInstance. i am... that your system does not find the image, you have specified.Set the path of an image
Jsp Absolute Path
Jsp Absolute Path   ... the absolute path in jsp. The absolute path is the full path that contains the root directory instead of a few directories contained within the absolute path
how to show image as a link which path coming from database
how to show image as a link which path coming from database   iam not getting proper answer for it. I am using netbeans .the url coming instring from database ,want to display as image on jsp . please help me
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
PHP Get Absolute Path
This example shows you how you can get the absolute path of a file. We... can get the absolute path of the file. ADS_TO_REPLACE_1 Code: <?php//to know your absolute path ADS_TO_REPLACE_2 echo realpath(dirname("
Getting a absolute path
Getting a absolute path     .... To find an absolute path of a file, Firstly we have to make a class... the name of the file whose absolute path you want to know. Now call the method
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
ModuleNotFoundError: No module named 'lektor-root-relative-path'
ModuleNotFoundError: No module named 'lektor-root-relative-path'  Hi...: No module named 'lektor-root-relative-path' How to remove the ModuleNotFoundError: No module named 'lektor-root-relative-path' error? Thanks  
Java file absolute path
Java file absolute path In this section, you will learn how to get the absolute path of the file. Description of code: If you want to locate a file without requiring further information, you can use absolute path. It always contain
image is display from path of mysql database
image is display from path of mysql database  <%@ page import="java.io.,java.sql.,java.util.zip.*" %> <% String saveFile=""; String..._path) values(?)"); psmnt.setString(1, ff.getPath()); int s = psmnt.executeUpdate
Java get Absolute Path
Java get Absolute Path       In this section, you will study how to obtain the absolute path... file.getAbsolutePath() returns the absolute path of the given file.  ADS
how to store image in folder and stored image path in mysql database using JSP
how to store image in folder and stored image path in mysql database using JSP  how to store image in folder and stored image path in mysql database using JSP
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
to obtain image path
or BROWSE button . and i am expecting to obtain the complete path of the image from...to obtain image path   i have made a web application in which you can upload a file and i have used File image = new File(image); here String image
Full path of image to save it in a folder
Full path of image to save it in a folder  Sir ,I am trying to upload... to find that image path &upload it as well. I am just a beginner in jsp... that the part where I set the path for storage has to be either one of local context
storing images in directory,saving path in db2
in a folder and its path(relative/absolute) in my DB2 database. and when the user logins, i shall retrieve the image and show it as the profile image again...storing images in directory,saving path in db2  i am working in a web
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database... in database and the file in folder I have created a form for the upload of files, for example, i need to save a image for the photo of candidate and resume
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database
Oracle database and I want to know how to retrieve the path of the file... as they are divided into many subfolders. I am currently just creating external table for each spreadsheet but I want to obtain the path and filename of each
pls provide common path to set image in flex - XML
pls provide common path to set image in flex  hi, pls provide common setpath to image in flex.when i give ful path like these C:\eclipse\workspace\mannai1\src\pictures\useful_links_logo.gif .it works nicely.but when i set path
Java IO Path
in the above image the absolute path will be C:\user\user2\xyz.txt Relative Path... there can be two types of path either 'relative' or 'absolute'... in the above image the relative path will be \user2\xyz.txt. The relative path
should i reboot physical server to change the JDK path in linux server
should i reboot physical server to change the JDK path in linux server  Hi i need to change the JDK path in linux server. I set the JDK path export JAVAHOME=/usr/java/jdk1.5.007/bin/java export PATH=$PATH:/usr/java/jdk1.5.0_07
downloading file through a file's path stored in database in jsp
in a database,i have done the coding for retrieving the path from database to a html table,but i dont know hoe to download the file using its path stored...downloading file through a file's path stored in database in jsp  hi
Inserting Image in a database Table
Inserting Image in MySql Database Table... understand the concept of inserting a image in the database table, so go through... As we have to insert an image file in our database so there is a need to use
path classpath
path classpath  EXPLAIN PATH AND CLASSPATH ? DIFF send me ans plz..., Path is system wide variable that tells where to find your commands. Lets... be in path. While Classpath is Enviroment Variable that tells JVM or Java Tools where
Path was not found
Path was not found  The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
Getting path name of uploading file in struts 2.8.1
Getting path name of uploading file in struts 2.8.1  Hai! I am using struts 2.8.1. I want to upload file into database with the path name. How can I... the temporary path not the original path. What I do
Java Path Class
that whether the current path is absolute or not. Syntax : boolean isAbsolute... to get the relative path from the current path, the returned path...Java Path Class In this section we will discuss all the aspect of Path class
How to use Java Path class?
are planning to use I/O functionality of Java then learn this Path class... specifies that whether the current path is absolute or not. Syntax : boolean...) This method is used to get the relative path from the current path, the returned path
How to get project path
How to get project path  my problem is,i have one jar file,in that one xml is their,i am adding this jar file to my project,my question is how i can open or get that xml path
How to get project path
How to get project path  my problem is,i have one jar file,in that one xml is their,i am adding this jar file to my project,my question is how i can open or get that xml path
Class Path - Java Beginners
Class Path  Hello I was able to set the class path as You have specified in the site... But still am not able to compile the "javac" command...; there u can type the path both in user variables for administrator   Hi
Inserting Image in Database Table
Inserting Image in Database Table   ... an image is inserted into the database, it displays ?Inserting Successfully... This program helps the user to insert an image in the MySQL database table
inserting image in mysql database using browse button in servlets
inserting image in mysql database using browse button in servlets  Hi,I want to insert a image in mysql database using browse button. and, i want to display all inserted images in a form from there i want to download the image
path problem - Java Beginners
path problem  I dont know how to set the path. What path should we set in environment variable for POI. I have downloaded and copied poi-3.2...-FINAL-20081019.jar in jdk's lib folder. I entered path as "C:\Program Files\Java
Problem in getting file path in js
Problem in getting file path in js  hi, I am using ofbiz framework , How i can get the file path in javascript for input type = "file" and i am using only firefox not other browser. so please help me it is very important for me
problem in setting path - Ant
problem in setting path  hi friends i am getting a problem in setting.../answers/viewanswers/3015.html but i am not getting plz check once and give me the reply its urgent  Hi friend, Your code : i setted the path
hibernate record not showing in database - Hibernate
hibernate record not showing in database  session =sessionFactory.openSession(); //inserting rocords in Echo Message table...)); //It showing on console Records inserted 21 But not showing in database

Ads