<html:file> tag works fine when i deployed my application on windows server and client is upload the file from windows machine.It is giving "Unknown Source" once i deployed application on Linux server and client is upload the file from windows machine.
This is something to do with the File Separator.
Even though i changed the File Separator manually from "\" to "/" still its not working and it is giving "File Not Found Exception".
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.
html:file tags should use FormFile fields.
naveen chedella
Greenhorn
Joined: Dec 05, 2008
Posts: 8
posted
0
But the FormFile will not give complete User File Path.I tested with the following example.
JSP:
External Power Forecast Data File : <html:file property="theFile" name="StrutsUploadForm "/> // I have Uploaded D:\EXT_FORECAST_DATA_21012009121212 file from the Browser
Form Bean:
public class StrutsUploadForm extends ActionForm
{
private FormFile theFile; /**
* @return Returns the theFile.
*/
public FormFile getTheFile() {
return theFile;
}
/**
* @param theFile The FormFile to set.
*/
public void setTheFile(FormFile theFile) {
this.theFile = theFile;
}
}
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class StrutsUploadAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
StrutsUploadForm myForm = (StrutsUploadForm)form;
// Process the FormFile
FormFile myFile = myForm.getTheFile();
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
System.out.println("contentType: " + contentType);
System.out.println("File Name: " + fileName); // This gives EXT_FORECAST_DATA_21012009121212.CSV only but i need Directory name and FileName to Retrive the data from the file in corressponding directory
What would you do with the path from the client machine anyway? Nothing--and some browsers don't even *send* the entire path, so it doesn't matter if you have it or not.
naveen chedella
Greenhorn
Joined: Dec 05, 2008
Posts: 8
posted
0
i needed to read the complete file name to display to the user that he has selected this particular file name and need to read the contents of the file and if the file is not valid then rename the file as Rejected and place it in the directory where client picked the actual file.Thats why i take it as String Property in the form bean and it is perfectly worked when application is deployed in the Windows Machine and client is accessed through browser in Windows machine but this is giving problem when i deployed on the Linux server and client is accessed in Windows machine.
Please help me in this regard.... And this is nothing to do the formfile and this is some thing regarding file separator