I am using struts 2.2.1 framework with jdk 1.6 and running in tomcat 7. In my web application, I want to upload excel file and read the content of that file. I have searched many websites and even apache website as well but I could not solve my problem.
After uploading file, when I try to read the uploaded file, error occurs : java.lang.NullPointerException. I think the variable "upload" in java file, should automatically initialized after file upload. isn't it?
struts inteceptor remove the temp file once the file is uploaded so you need to copy files with file. Also as far as nullpointer exception is concern you need to check the configuration. I have used your code in sample application and uploaded file with minor changes.
You need to copy the uploaded file then you will be able to see it.
It did work for me . You need to store the uploaded file in db or some location on server as struts inteceptor removes the file uploaded and you wont be able to see in your system. It gives you the info in the console like
INFO: Removing file upload E:\workspace1.5\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\struts2\upload__3c0968c2_139dd3c2d69__8000_00000001.tmp .
You can print the filename in setuploadfilename method where you can see the full path where the struts is uploading the file.