You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Agnes Laffitte <ag...@gmail.com> on 2008/08/29 19:21:32 UTC
Displaying the output file using apache fileupload
Hello,
by using java i have read an input file and written the output file. Now I
want the server to display the content of the output file.
I have the output file name, and the method I used to write the output file
was by using the following fragment of code:
PrintWriter out = new PrintWriter(System.currentTimeMillis() + outFile);
out.println("***************************************************");
out.println("*
*");
out.println("* RESULTS FROM SIMUROUTE PROJECT
*");
out.println("*
*");
out.println("***************************************************");
out.println("\r\n");
out.println("***************************************************");
out.println("* COSTS MATRIX
*");
out.println("***************************************************");
out.println("\r\nCOSTS MATRIX:\n");
for (int i = 0; i < nodesList.size(); i++)
for (int j = 0; j <= i; j++)
out.println(i + " " + j + " " + Distance1[i][j]);
out.close();
}
catch (IOException exception)
{
System.out.println("Error processing output file: " +
exception);
}
}
Let me know how to display this content to the client. I have code that
receive the file from the client using the file upload widget and
this fragment of code:
private FileItem getFileItem(HttpServletRequest request) {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
try {
List<FileItem> items = upload.parseRequest(request);
for (FileItem item: items) {
if (!item.isFormField()
&& "uploadFormElement".equals(item.getFieldName()))
{
return item;
}
}
} catch (FileUploadException e) {
return null;
}
return null;
}
Your attention to this matter is highly appreciated.
Sincerely,
Agnes Laffitte