uws
Posts: 8
|
| Posted: 07/13/2005, 11:48 PM |
|
Ok guy here is my first big code I need to work on for my web.
I need to be able to have a CSV or text file uploaded in to my database how would I go about doing that I tried everything on the web the closet thing I found can't do one major thing and it requres separate logins.. Here is a short ver. of what I got
col1 col2 col3..... I need it to import into a table lets say table inventory...but col2 data is always numeric for example number 4 so if importing col2 I need it to change the number 4 into hbo and insert it into col3 when it imports it.. If Col2 data equals 4 change to hbo / if equals 5 change to sho ECT... but insert it into a column I want... any help would be great even if how to import... but I would like that col2 to change data.... I am u a percon top gun for scanning inventory...
|
 |
 |
jhon
|
| Posted: 07/21/2005, 4:39 PM |
|
similar problem but i just need the to now how to upload from the webpage
|
|
|
 |
GeorgeS
Posts: 206
|
| Posted: 07/22/2005, 12:13 PM |
|
uws,
as I understood you are trying to upload csv file and insert the content of this file into a table changing values of the fields in the time of insertion.
I'm not sure what "it requres separate logins" mean in this case?
_________________
GeorgeS |
 |
 |
uws
Posts: 8
|
| Posted: 07/25/2005, 8:03 AM |
|
the seprate login was using a difrenrt 3rd party software i don't need that all i need is what you said //////////trying to upload csv file and insert the content of this file into a table changing values of the fields in the time of insertion.//
|
 |
 |
dave
|
| Posted: 08/16/2005, 7:23 PM |
|
can anyone answer this ???
|
|
|
 |
momo
|
| Posted: 08/26/2005, 9:01 AM |
|
put this piece of code on your servlet that u r posting to:-
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
DiskFileUpload fu = new DiskFileUpload();
List pList = fu.parseRequest(req);
Iterator i = pList.iterator();
String dest = null;
String contents = null;
while (i.hasNext()) {
FileItem item = (FileItem) i.next();
if (item.isFormField()) {
System.out.println("formfield:"+item.getFieldName()+"="+item.getString());
if (item.getFieldName().equals("redirect")) {
dest = item.getString();
}
} else {
System.out.println("filefield:"+item.getFieldName()+"="+item.getContentType()+",length="+item.get().length);
contents = new String(item.get());
}
}
} catch (FileUploadException e) {
e.printStackTrace();
}
}
|
|
|
 |
momo
|
| Posted: 08/26/2005, 9:04 AM |
|
I forgot u need to download a commons-fileupload.jar and add it to your project
|
|
|
 |