Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

problem uploading .xls file

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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="" 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.lang.Object;
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

Posts: 9691
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
    Bookmark Topic Watch Topic
  • New Topic