Web Server: Sun Java System Web Server 7 update 5

I have inherited a JSP application and am trying to get it to work. I have figured out that it has something to do with the <input type="file"> tag, because I cut all the rest of the code out.

<input type="file" name="file_upload" maxlength="150" size="20" />
<input type="submit" name="UploadFile" value="Upload File" class="btn" onclick="return validate()" />

On submit, I get the following error:

javax.servlet.jsp.JspTagException: The file could not be written: java.io.FileNotFoundException: C:\WebApps\gpr\uploads\attachments\5217\c\DocumentsandSettings\gzjs4n\MyDocuments\227342050034.xls (The system cannot find the path specified)
	xephyrus.taglibs.fileupload.WriteTag.doEndTag(WriteTag.java:103)
	org.apache.jsp.att.attach_jsp._jspService(Unknown Source)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:80)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:917)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:457)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:351)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:917)
	com.cj.trim.trimFilter.doFilter(Unknown Source)

Notice how the error is referring to the file name as "C:\WebApps\gpr\uploads\attachments\5217\c\DocumentsandSettings\gzjs4n\MyDocuments\227342050034.xls". Basically, it is adding the whole (including path) name of the file instead of just taking the file name, which is "227342050034.xls". Since I have no other code creating this name, I do not know why this is happening.

Note: this could be a configuration problem, since I set up the Web Server myself and have not had any other experience doing this.

Dumb Question: Does the path that it is complaining about exist?

Dumb Question: Does the path that it is complaining about exist?

No. The path is not correct. It is tacking the whole directory to the end of the base directory. It would be correct if it was not doing that.

How do I add an update to my thread in this forum? Do I just create a reply like I am doing?

Here is the update: I found out that it is not the INPUT field that is causing the problem. But there is some client-side Javascript code that is executing on SUBMIT. So, I will look into that now.

function validate()
{

	var strTemp = document.frmAtt.fileDesc.value;
	var strTemp2 = document.frmAtt.file_upload.value;	
	
	strTemp2 = trimAll(strTemp2);

    if(strTemp2.length <= 0)
	{
	alert('The filename can not be blank. File not uploaded.');
	return false;
	}
	
    if(strTemp2.length > 150)
	{

	alert('Please enter a path and filename less than or equal to 150 characters. File not uploaded.');
	return false;
	}	
	
	strTemp = trimAll(strTemp);

    if(strTemp.length <= 0)
	{
	alert('Please enter a link description. File not uploaded.');
	return false;
	}
	else
	{
	return confirm('Upload the file?');
    }
    
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.