• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException in File name Struts

 
Franck Reivax
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sandy Chatterjee
Ranch Hand
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
Hibernate Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic