wood burning stoves 2.0*
The moose likes Struts and the fly likes Problem with Form File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with Form File" Watch "Problem with Form File" New topic
Author

Problem with Form File

naveen chedella
Greenhorn

Joined: Dec 05, 2008
Posts: 8
I am using a Form File for file Upload in my application.In this i am getting a strange problem.

Input.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:form action="/LoadPowerForecast" method="post" enctype="multipart/form-data"> </html:form>
External Power Forecast Data File : <html:file property="theFile"/></[/b]td>
   
<html:submit property="method"><bean:message key="LoadPower.Load"/></html:submit>


Form Bean:
package com.ngt.wpfs.forms;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;


public class LoadPowerForm extends ActionForm {
private FormFile theFile;
public void setTheFile(FormFile theFile) {
this.theFile = theFile;
}

public FormFile getTheFile() {
return theFile;
}
}

By clicking "Load" submit button,all the data is submitted and then processing is done in Action Class and the action class will forward back it input.jsp. But while displaying input.jsp from action class the file name which i have selected earlier is not showing in input.jsp .




David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Consider turning off HTML and USeCodeTags... surely you can see that something went wrong?
naveen chedella
Greenhorn

Joined: Dec 05, 2008
Posts: 8
I have removed unneccessary HTML tags and still it does not work....

Modeified Input.jsp

Input.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

<html:form action="/LoadPowerForecast" method="post" enctype="multipart/form-data">


<html:file property="theFile"/></td>


<html:submit property="method"><bean:message key="LoadPower.Load"/></html:submit>

</html:form>

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

See the "Disable HTML" checkbox? Check it, in a new post, with the real code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Form File
 
Similar Threads
struts file upload problem
Map the action form object
Struts 1.2.4 File Upload - Form File is null in action
Displaying file content in a jsp page
html:form enctype="multipart/form-data"