This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in updating values into database

g anil kumar
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....
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic