wood burning stoves 2.0*
The moose likes JSP and the fly likes http status error 404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "http status error 404" Watch "http status error 404" New topic
Author

http status error 404

nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
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
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

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


SCJP, SCWCD.
|Asking Good Questions|
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
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

Joined: Jun 06, 2007
Posts: 2716
    
    6

You are welcome,
Its always a pleasure to help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: http status error 404
 
Similar Threads
problem with commons FileUpload
File Upload Error
Upload files from client
getting error while uploading file
Problem with File Upload