This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
You should only use enctype="multipart/form-data" if you're uploading a file. If you're not uploading a file, remove this part of the <html:form> tag. If you are uploading a file, use <html:file> and make a property of type FormFile with the corresponding attribute name on your ActionForm. Then everything should work properly. [ October 23, 2006: Message edited by: Merrill Higginson ]
I need to upload a file in my struts form. I tried this already. I have an Actionform where I defined a variable of type formfile that corresponds to <html:file > property. I have a html:submit and a hidden field whose value I am trying to get in the Actions execute.It always returns null
I believe the value attribute in hidden element is bean to be used not the actual value you want to submit. To make things easier to debug, initialize your hidden attribute to "submit" in action form's reset() method and test it.
Joined: Feb 15, 2005
In this thread you will find a good explanation by Travis Hein about what's actually happening internally when you specify enctype="multipart/form-data". After reading this, you'll understand why you can't get the parameter directly from the request. However, you should be able to get it from the ActionForm's getter method for the property. Are you 100% sure that this always yeilds null?
Joined: Oct 20, 2004
Merrill, thanks for pointing me to this thread. that gives me a good insight.. But my case is really weird I am not able to get the values even through the form. I am 100% sure it is returning null. It behaves as if it is not at all binding the html form values to the action form .
I checkes my Struts Config everything looks good there.
Does the scope of the form matter. In my case it is "request".
Joined: May 24, 2003
I was completely wrong on my earlier post. Anyway, Instead of guessing what's wrong why don't you dump the Servlet's inputstream to verify the content. If you have a filter you can write small snippet to retrieve the inputstream and dump the content (Remember this has to be done before control is passed to actionservlet). If hidden param is part of request you can confirm that.
Or you can think about some proxy stuff to view the request made from the client.