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]

[1740 byte] By [subhashmedhia] at [2007-11-27 11:09:43]
# 1

When you post code, please use[code] and [/code] tags as described here http://forum.java.sun.com/help.jspa?sec=formatting on the message entry page. It makes it much easier to read.

cotton.ma at 2007-7-29 13:37:13 > top of Java-index,Java Essentials,Java Programming...
# 2

ok.but could you please help me with this stuff?

subhashmedhia at 2007-7-29 13:37:13 > top of Java-index,Java Essentials,Java Programming...
# 3

> ok.but could you please help me with this stuff?

Could you please help us help you by reposting your code with proper code tags so it doesn't look something a marmot threw up?

cotton.ma at 2007-7-29 13:37:13 > top of Java-index,Java Essentials,Java Programming...
# 4

I have a jsp form whose code i am including below:

<%@ 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>.

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:

if((url_Display != null)){

System.out.println("Got a string.");

return mapping.findForward("UploadSuccess");

}

else {

System.out.println("Null value");

return mapping.findForward("UploadFailure");

}

}

}

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 variable in the bean class to a string of 40 blank-spaces?

Kindly help!!

subhashmedhia at 2007-7-29 13:37:13 > top of Java-index,Java Essentials,Java Programming...