• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

http status error 404  RSS feed

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends iam trying to upload 3 files in the desktop using FileUpload concept but i get the following error in the browser

i am using netbeans and the following message is the error message displayed





HTTP Status 404 - C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)



--------------------------------------------------------------------------------



type Status report



message C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)



description The requested resource (C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)) is not available.





--------------------------------------------------------------------------------



Apache Tomcat/5.5.9








The following two jsp codes are codes that i used



UploadFiles.jsp







<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">



<HTML>

<HEAD>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252"/>

<TITLE>File Upload Page</TITLE>

</HEAD>

<BODY>Upload Files

<FORM name="filesForm" action="pf.jsp"

method="post" enctype="multipart/form-data">

File 1:<input type="file" name="file1"/><br/>

File 2:<input type="file" name="file2"/><br/>

File 3:<input type="file" name="file3"/><br/>

<input type="submit" name="Submit" value="Upload Files"/>

</FORM>

</BODY>

</HTML>







pf.jsp







<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">



<%@ page contentType="text/html;charset=windows-1252"%>

<%@ page import="org.apache.commons.fileupload.DiskFileUpload"%>

<%@ page import="org.apache.commons.fileupload.FileItem"%>

<%@ page import="java.util.List"%>

<%@ page import="java.util.Iterator"%>

<%@ page import="java.io.File"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Process File Upload</title>

</head>

<%

System.out.println("Content Type ="+request.getContentType());



DiskFileUpload fu = new DiskFileUpload();

// If file size exceeds, a FileUploadException will be thrown

fu.setSizeMax(1000000);



List fileItems = fu.parseRequest(request);

Iterator itr = fileItems.iterator();



while(itr.hasNext()) {

FileItem fi = (FileItem)itr.next();



//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());

//System.out.println(fi.getOutputStream().toString());

File fNew= new File(application.getRealPath("/"), fi.getName());



System.out.println(fNew.getAbsolutePath());

fi.write(fNew);

} else {

System.out.println("Field ="+fi.getFieldName());

}

}

%>

<body>

Upload Successful!!

</body>

</html>



Kindly do help me in this regard......... Thank you in advance
 
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As you did not use code tags so I did not look at your code but,

C:\Documents and Settings\HU68135\file\build\web\C:\Documents and Settings\HU68135\Desktop\a.txt (The filename, directory name, or volume label syntax is incorrect)



the above line suggests that there is a problem with the path of the file name and maybe not with the code.


Hope this helps
 
nidhivel raja
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for your reply Mr.Amit Ghorpade. I found out my exact problem, I did not include a line in that code and the problem that i faced was because of my browser.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome,
Its always a pleasure to help
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!