• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

html:form enctype="multipart/form-data"

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using <html:form>in my jsp where i am using attribute enctype="multipart/form-data" coz i gotta upload a file. along with that i also have a text field in the same html form. So because of the enctype tag, the text field is also getting encrypted and my actionform is not getting populated with the text field value and hence my action class is not performing the desired operation. How to handle this problem when my html form is having both "file" and "text" fields.


regards..

[ EJFH: See this. ]

[ December 05, 2005: Message edited by: Ernest Friedman-Hill ]

[ December 05, 2005: Message edited by: Sam Mites ]
[ December 05, 2005: Message edited by: Sam Mites ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have forms that use both upload files and other input fields that work fine, so I know it can be done. I'd suggest that you study carefully the upload example that comes with the Struts download. It has an input field as well as a file upload field.
 
Sam Mites
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merrill,
I studied it, and doing the same thing.but still I am getting the same problem.Can u supply me with some sample code.

thanks and regards
 
Sam Mites
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merrill,

Thank u very much for the files. I went theough them. I still cant able to find the flaw in my code..

here are my sample code...the jsp

<html:form action="/protect/xccManageSolutionComponentsAdd.wss" method="post" enctype="multipart/form-data">
<!--here i am uploading the files-->
<table>
<tr>
<td width="30%">Add CFReport:</td>
<td width="30%" colspan="3"><html:file property="cfReport" size="50" /></td>
<td> </td>
</tr>
<tr>
<td width="25%">Add SEO csv file:</td>
<td width="30%" colspan="3"><html:file property="seoCsvFile" size="50" /></td>
</tr>
<!--here are my text fields -->
<tr>
<table>
<tr>
<td> Type : <html:text property="mesType" size="8" />  </td>
<td> Model :<html:text property="mesModel" size="8" />  </td>
<td> Feature/RPQ : <html:text property="mesFeature" size="12" /></td>
</tr>
</table>
</tr>
<tr>
<td align="right" colspan="5"><span class="button-gray">
<html:submit value="Add" /> </span></td>
</tr>
</table>
</html:form>

here is my form bean

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import org.apache.struts.upload.FormFile;
public class XCCManageSolutionComponentsForm extends ActionForm
{
private FormFile cfReport;
private String mesFeature;
private String mesModel;
private String mesType;
private FormFile seoCsvFile;
public FormFile getCfReport()
{
return cfReport;
}
public String getMesFeature()
{
return mesFeature;
}
public String getMesModel()
{
return mesModel;
}
public String getMesType()
{
return mesType;
}
public String getSearchSeo()
{
return searchSeo;
}
public FormFile getSeoCsvFile()
{
return seoCsvFile;
}
public void setCfReport(FormFile cfReport)
{
this.cfReport = cfReport;
}
public void setMesFeature(String mesFeature)
{
this.mesFeature = mesFeature;
}
public void setMesModel(String mesModel)
{
this.mesModel = mesModel;
}
public void setMesType(String mesType)
{
this.mesType = mesType;
}
public void setSeoCsvFile(FormFile seoCsvFile)
{
this.seoCsvFile = seoCsvFile;
}

}

does the jsp and the form bean need change..???

thanks and regards
 
Sam Mites
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
plz refer to the above code...

When i run the server in the debug mode...in case of enctype="multipart/form-data" the form bean is not getting called. the control was directly going to the action class. Henct the form bean data were not populated and i am not able to access the data.

What may be the reason behind the action form not getting called??

when i am running this code without enctype="multipart/form-data" then every thing is ok and the form bean was called before the control goes to the acton class!!!

Thanks and regards
 
please buy this thing and then I get a fat cut of the action:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!