File upload
[nobr]I have a jsp form whose code i am including below:
[i]<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<html:form action="UploadFile">
Please specify a file, or a set of files:
<input type="file" name="url" size="40">
<div>
<input type="submit" value="Send">
</div>
</html:form>[/i]
This form generates a browse option to select any file whose URI it sends to a form bean. the Action class returns an ActionForward "UploadSuccess" and another ActionForward "UploadFailure".
Logically, if a file is selected and the submit button is pressed then the first ActionForward should be returned and the corresponding html page should be displayed and if i don't select any file but simply press the submit button the second ActionForward should be returned and the corresponding html page be displayed.
I am including a fragment of the Action class below:
[code][if((url_Display != null)){
System.out.println("Got a string.");
return mapping.findForward("UploadSuccess");
}
else {
System.out.println("Null value");
return mapping.findForward("UploadFailure");
}
}
}
/code] where url_Display is the string variable in the Action class where we retrieve the value of the URI for the file stored in the bean.
But for both the cases I am getting the same response as that should be for the first case. Why is it so? The file name could be of size 40. So even if i don't select any file,does it set the corresponding String value in the bean to a string of 40 blank-spaces?
Kindly help.[/nobr]

