wood burning stoves 2.0
The moose likes Struts and the fly likes problem uploading .xls file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem uploading .xls file" Watch "problem uploading .xls file" New topic

problem uploading .xls file

Kirti Chopra

Joined: Sep 09, 2009
Posts: 1
hi all i am new to struts 2.0 trying to upload a file but getting null in SOP in my action class and 404 error my jsp is like this

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

<div class="centertb">

<div class="subTitleText" style="padding-left: 50px;">
<s:form method="POST" enctype="multipart/form-data" theme="simple">
<table width="80%" style="font-weight: normal;">
<s:file name="file" label="File"></s:file>
<td><s:submit action="uploadXls"cssClass="submitButton" label="upload xls" align="left" cssStyle="margin-left:100px;"/></td>

action class i am trying this:

import java.io.File;
import java.lang.Object;
import org.apache.commons.io.FileUtils;
import com.sun.deploy.cache.Cache;

* Created by IntelliJ IDEA.
* User: Owner
* Date: Sep 9, 2009
* Time: 10:22:18 AM
* To change this template use File | Settings | File Templates.
public class UploadXlsAction extends BaseAction {
private File file;
private String uploadContent;
private String fileName;
private UploadXlsAction upload;
public String execute() throws Exception
String filepath=file.getAbsolutePath();

return "success";
public File getFile() {
return file;

public void setFile(File file) {
this.file = file;

public String getUploadContent() {
return uploadContent;

public void setUploadContent(String uploadContent) {
this.uploadContent = uploadContent;

public String getFileName() {
return fileName;

public void setFileName(String fileName) {
this.fileName = fileName;

public void uploaded(File file, String fileName, String directoryName){
File dir = new File(directoryName);
if (!dir.exists()) {
String targetPath = dir.getPath() + File.separator + fileName;
File fileDestination = new File(targetPath);
FileUtils.copyFile(file, fileDestination);



Please help

Ankit Garg

Joined: Aug 03, 2008
Posts: 9463

Hi Kirti, welcome to javaranch.

Kirti please Use Code Tags when you post a source code. Edit your message using button and then add code tags to it.

Also can you confirm that the interceptor stack that you are using for this action has the file-upload-interceptor in it...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link: http://aspose.com/file-tools
subject: problem uploading .xls file
jQuery in Action, 3rd edition