appears that you are using an older version of struts (before the integration of xwork to struts framework)
can you refactor to struts 2.3.4 and follow the showcase example for filedownload \struts-2.3.4\src\apps\showcase\src\main\java\org\apache\struts2\showcase\filedownload /* * $Id: FileDownloadAction.java 496318 2007-01-15 13:58:24Z husted $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.struts2.showcase.filedownload;import java.io.InputStream;import org.apache.struts2.ServletActionContext;import com.opensymphony.xwork2.Action;/** * Demonstrates file resource download. * Set filePath to the local file resource to download, * relative to the application root ("/images/struts.gif"). * */ public class FileDownloadAction implements Action { private String inputPath; public void setInputPath(String value) { inputPath = value; } public InputStream getInputStream() throws Exception { return ServletActionContext.getServletContext().getResourceAsStream(inputPath); } public String execute() throws Exception { return SUCCESS; }} be careful on the first pass to only upload picture types specified in allowedTypes param name="allowedTypes"> > image/gif,image/jpeg,image/png > </param> Martin ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Sat, 16 Mar 2013 22:28:03 +1100 > Subject: Re: Null Pointer Exception when i use execand Wait with file upload > From: stalin.pran...@gmail.com > To: user@struts.apache.org > > <action name="File_singleUpload" class="employee.SingleFileUploadAction" > method="upload"> > <interceptor-ref name="fileUpload"> > <param name="maximumSize">1000000000</param> > <param name="allowedTypes"> > image/gif,image/jpeg,image/png > </param> > </interceptor-ref> > <interceptor-ref name="defaultStack"/> > <interceptor-ref name="execAndWait"> > <param name="delay">1500</param> > </interceptor-ref> > <result name="wait">/jsp/wait.jsp</result> > <result name="success">/jsp/SingleUpload.jsp</result> > </action> > > On 16 March 2013 22:16, Martin Gainty <mgai...@hotmail.com> wrote: > > > so the line ServletActionContext.getServletContext(); is NPE > > > > please display configuration for your Action from struts*.xml > > > > Martin ______________________________________________ > > Verzicht und Vertraulichkeitanmerkung > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > > dient lediglich dem Austausch von Informationen und entfaltet keine > > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > > > Date: Sat, 16 Mar 2013 12:18:30 +1100 > > > Subject: Re: Null Pointer Exception when i use execand Wait with file > > upload > > > From: stalin.pran...@gmail.com > > > To: user@struts.apache.org > > > > > > :) Apologies > > > > > > > > > package employee; > > > > > > import com.opensymphony.xwork2.ActionSupport; > > > import org.apache.struts2.ServletActionContext; > > > > > > import javax.servlet.ServletContext; > > > import java.io.File; > > > > > > /** > > > * Created with IntelliJ IDEA. > > > * User: love4059 > > > * Date: 13/03/13 > > > * Time: 8:10 PM > > > * To change this template use File | Settings | File Templates. > > > */ > > > public class SingleFileUploadAction extends ActionSupport { > > > private String description; > > > private File attachment; > > > private String attachmentContentType; > > > private String attachmentFileName; > > > private int complete = 0; > > > public String getDescription() { > > > return description; > > > } > > > > > > public void setDescription(String description) { > > > this.description = description; > > > } > > > > > > public String getAttachmentContentType() { > > > return attachmentContentType; > > > } > > > > > > public void setAttachmentContentType(String attachmentContentType) { > > > this.attachmentContentType = attachmentContentType; > > > } > > > > > > public File getAttachment() { > > > return attachment; > > > } > > > > > > public void setAttachment(File attachment) { > > > this.attachment = attachment; > > > } > > > > > > public String getAttachmentFileName() { > > > return attachmentFileName; > > > } > > > > > > public void setAttachmentFileName(String attachmentFileName) { > > > this.attachmentFileName = attachmentFileName; > > > } > > > > > > public String upload(){ > > > System.out.println(description); > > > System.out.println(attachmentContentType); > > > System.out.println(attachmentFileName); > > > ServletContext servletContext = > > > ServletActionContext.getServletContext(); (NULL POINTER > > > Exception at this LINE) > > > if (attachment != null) { > > > // attachment will be null if there's an error, > > > // such as if the uploaded file is too large > > > String dataDir = servletContext.getRealPath("/WEB-INF"); > > > System.out.println(dataDir); > > > File savedFile = new File(dataDir, attachmentFileName); > > > attachment.renameTo(savedFile); > > > } > > > return "success"; > > > } > > > > > > > > > > > > public int getComplete() { > > > complete += 10; > > > return complete; > > > } > > > } > > > > > > > > > 2013/3/16 Martin Gainty <mgai...@hotmail.com> > > > > > > > Not much anyone can do here if we cant see the code for > > > > employee.SingleFileUploadAction.java > > > > > > > > Martin > > > > ______________________________________________ > > > > Verzicht und Vertraulichkeitanmerkung > > > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > > > > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede > > unbefugte > > > > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese > > Nachricht > > > > dient lediglich dem Austausch von Informationen und entfaltet keine > > > > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von > > > > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. > > > > > > > > > > > > > Date: Sat, 16 Mar 2013 10:21:08 +1100 > > > > > Subject: Null Pointer Exception when i use execand Wait with file > > upload > > > > > From: stalin.pran...@gmail.com > > > > > To: user@struts.apache.org > > > > > > > > > > Hello I am trying to use execandWait interceptor with fileUpload > > > > > interceptor as below. i tried completestack in place of default and > > i get > > > > > Null pointer exception. > > > > > > > > > > > > > > > <action name="File_singleUpload" > > class="employee.SingleFileUploadAction" > > > > > method="upload"> > > > > > <interceptor-ref name="fileUpload"> > > > > > <param name="maximumSize">1000000000</param> > > > > > <param name="allowedTypes"> > > > > > image/gif,image/jpeg,image/png > > > > > </param> > > > > > </interceptor-ref> > > > > > <interceptor-ref name="defaultStack"/> > > > > > <interceptor-ref name="execAndWait"> > > > > > <param name="delay">1500</param> > > > > > </interceptor-ref> > > > > > <result name="wait">/jsp/wait.jsp</result> > > > > > <result name="success">/jsp/SingleUpload.jsp</result> > > > > > </action> > > > > > > > > > > > > > > > java.lang.NullPointerException > > > > > > > > > > > org.apache.struts2.ServletActionContext.getServletContext(ServletActionContext.java:139) > > > > > > > > > employee.SingleFileUploadAction.upload(SingleFileUploadAction.java:58) > > > > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > > > > > > > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > > > > > > > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > > > > > java.lang.reflect.Method.invoke(Method.java:597) > > > > > > > > > > > com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:446) > > > > > > > > > > > com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:285) > > > > > > > > > > > org.apache.struts2.interceptor.BackgroundProcess$1.run(BackgroundProcess.java:57) > > > > > java.lang.Thread.run(Thread.java:680) > > > > > > > > > > > > > > > > > > > > Please advise what i can do. > > > > > > > > > > > > > > > -- > > > > > Warm Regards > > > > > Pranava S Balugari > > > > > > > > > > "Keep Looking Don't Settle" > > > > > > > > > > > > > > > > > > > > -- > > > Warm Regards > > > Pranava S Balugari > > > > > > "Keep Looking Don't Settle" > > > > > > > > -- > Warm Regards > Pranava S Balugari > > "Keep Looking Don't Settle"