Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in updating values into database  RSS feed

Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to upload a file and at the same time i need the field values and to update the file path and the name field to br updated into database.
I'm using apache commons file uploading
this is the program for file uploading
<%@ page language="java" %>

<BODY> <FORM ENCTYPE="multipart/form-data" ACTION="uploadbyapache1.jsp" METHOD=POST>
<table border="0" bgcolor=#ccFDDEE>
<td colspan="2" align="center"><B>UPLOAD THE FILE</B><center></td>
<td colspan="2" align="center"> </td>
<td><b>Choose the file To Upload:</b></td>
<td><INPUT NAME="filename" TYPE="file"></td>
Name<INPUT NAME="name" TYPE="text"></td>
<td colspan="2" align="center"> </td>
<td colspan="2" align="center"><input type="submit" value="Submit"> </td>


<%@ page import="*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page import="org.apache.commons.fileupload.*" %>
String name;
System.out.println("Content Type ="+request.getContentType());

DiskFileUpload fu = new DiskFileUpload();
// If file size exceeds, a FileUploadException will be thrown

List fileItems = fu.parseRequest(request);
Iterator itr = fileItems.iterator();

while(itr.hasNext()) {
FileItem fi = (FileItem);

//Check if not form field so as to only handle the file inputs
//else condition handles the submit button input
if(!fi.isFormField()) {

System.out.println("\nNAME: "+fi.getName());
System.out.println("SIZE: "+fi.getSize());
File tempFileRef = new File(fi.getName());

//Create a new directory
File testDir = new File("C:\\anil");
if ( !testDir.exists() ){

//"C:\\Tomcat 5.5\\webapps\\start2finish\\ImageUploads"

if (fi.getName() != "") {
File fNew= new File("C:\\anil",tempFileRef.getName());
else {
name =fi.getFieldName();
String value=fi.getString();
out.println(name+"this is outside block");
out.println("Field ="+fi.getFieldName());
this is texts<input name="name" type="text" value="<%=name%>">

I'm able to upload the file and also i got the field value by not able to understand how to update the filepath and the name into the database..
Please some one help me out...
Thank you....
To do a great right, do a little wrong - shakepeare. twisted little ad:
ScroogeXHTML 7.2 - RTF to HTML5 / XHTML converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!