Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC i am inserting an image into database but it is showing relative path not absolute path
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


praveen kumar reddy.y
i am inserting an image into database but it is showing relative path not absolute path
1 Answer(s)      4 years ago
Posted in : JDBC


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


Advertisement
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...("thank u for registration"); out.println("ur values are inserted into database
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...("thank u for registration"); out.println("ur values are inserted into database
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
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
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. Code: <?php//to know your absolute path echo realpath(dirname("absolutepath.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
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 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
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
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
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
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.    
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
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 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
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
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
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
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
inserting image into database
inserting image into database  how to insert image into database using struts frame work and spring JDBC
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
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
'relative' or 'absolute'. Absolute Path : Path for locating... path. for example, to locate a xyz.txt file in the above image the absolute path... to be located. for example, to locate a xyz.txt file in the above image the relative path
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
 

 

 

DMCA.com