| Author |
java.lang.NullPointerException in File name Struts
|
Franck Reivax
Greenhorn
Joined: Jul 07, 2012
Posts: 5
|
|
Hi there, I have a problem and I need help.
I´m working with Struts 1.3.10 in NetBeans 7.1.2, I'm developing a web app, I'm using jsp, well, I'm implementing a jsp where I upload a file, but is giving me problems. I have the next code and configurations.
In the JSP I have:
In the Form bean I have
In the Action I have
In the struts-config I have
And when I run the aplication, and I select the file, the server send me the exception "javax.servlet.ServletException: java.lang.NullPointerException". I mean my File name is becoming null in action class.
And I don´t know why, I expect can help me. thanks btw I´m sorry for my english
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
private UploadForm validator;
Make the declaration inside the execute() method of the Action Class.
Its advised to do it in Thread Safe manner.
Regards,
Sandy
|
Take up one idea. Make that one idea your life; dream of it; think of it; live on that idea. Let the brain, the body, muscles, nerves, every part of your body be full of that idea, and just leave every other idea alone. This is the way to success.
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
Your code is running perfectly fine in my Development Environment.
I am uploading .jpeg and .txt files.
Could you tell me what kind of files are you trying to Upload.
Regards,
Sandy
|
 |
Franck Reivax
Greenhorn
Joined: Jul 07, 2012
Posts: 5
|
|
|
Hi Sandy Chatterjee, thanks for your reply. I'm trying upload a pdf file. and When debugging the project I realized that the FormBean returns the variable "thefile" null.
|
 |
Franck Reivax
Greenhorn
Joined: Jul 07, 2012
Posts: 5
|
|
Really Running? I'm using NetBeans 7.1.2 and Struts 1.3.10, with the JDK jdk1.7.0_05 also I'm using GlassFish Server 3.1.2.
That could be happening?
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
I'm trying upload a pdf file. and When debugging the project I realized that the FormBean returns the variable "thefile" null.
Even pdf file is uploading in my system.
I'm using NetBeans 7.1.2 and Struts 1.3.10, with the JDK jdk1.7.0_05 also I'm using GlassFish Server 3.1.2.
I am using NetBeans 6.5 ,struts 1.2, JDK 1.5 and Glassfish 3.1.
But I don't think it has something to do with the version.
Do one thing start a completely new project in NetBeans and check.
Regards,
Ssandy
|
 |
Franck Reivax
Greenhorn
Joined: Jul 07, 2012
Posts: 5
|
|
I started a new project but still not working. What happens is that when I click on the button to upload the file throws me the following page:
the page says: "The webpage is not available"
And I think that's the reason why the formBean sends null.
|
 |
Franck Reivax
Greenhorn
Joined: Jul 07, 2012
Posts: 5
|
|
Fix it! Well, actually I changed my operating system, was using windows, and now I'm using ubuntu. But I think the problem is the jdk, and I saw in other forums that some people had the same problem as me, and the problem was the jdk. Solved the problem using JDK6.
Thank you!
|
 |
 |
|
|
subject: java.lang.NullPointerException in File name Struts
|
|
|