Uploading files

i want to upload files using servelets and jdbc,please guide me , how could i approch the solution,if any of you done it earlier please help me also.
[184 byte] By [arun_jassiar1] at [2007-9-26 3:47:04]
# 1
see www.servlets.com
yueksel at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

I am trying that code ,

But its not working,

i downloaded that package cos.jar for that

compiled that class,

but on action of form servlet is working

as pages get expired with result,

do me have make any change in that

Please eguide with details

Regards

Arun

arun_jassiar1 at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Use Oneclickdeal APIworks great. http://www.oneclickdeal.com
vladdoor at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

First download the cos.jar from http://www.servlets.com and put it in your classpath, then this works peacefully ....

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.*;

import com.oreilly.servlet.MultipartRequest;

public class UploadServlet extends HttpServlet {

public void doPost(HttpServletRequest req, HttpServletResponse res)

throws ServletException, IOException {

res.setContentType("text/html");

PrintWriter out = res.getWriter();

MultipartRequest multi = new MultipartRequest(req, "F:\\ksenji", 50 * 1024);

out.println("<HTML>");

out.println("<HEAD><TITLE>UploadTest</TITLE></HEAD>");

out.println("<BODY");

out.println("><H3>Files:</H3>");

out.println("<PRE>");

Enumeration files = multi.getFileNames();

while (files.hasMoreElements()) {

String name = (String)files.nextElement();

String filename = multi.getFilesystemName(name);

String type = multi.getContentType(name);

File f = multi.getFile(name);

out.println("name: " + name);

out.println("filename: " + filename);

out.println("type: " + type);

if (f != null) {

String s = f.getName();

out.println("length: " + f.length());

}

}

}

}

kksenji at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
i have try to run the above example...it can run well...but i wish to add the uploaded file to the database....how should i write in order to do that.....
munleng at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
use a CLOB or a BLOB to upload files to the database.
kksenji at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
hi kksenji,how to write it..can u show me some examplethanx
munleng at 2007-6-29 12:29:22 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...