File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException

 
Lek Kin Wong
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What the problem with this code, i got a java.lang.NullPointerException with it on my Tomcat7.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4122
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at the JavaDoc for File.listFiles() method.
Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.
 
Lek Kin Wong
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Devaka Cooray wrote:Please have a look at the JavaDoc for File.listFiles() method.
Returns:
An array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

thank.
well, i found what cause the problem, this is the jsp code how i get the parent path:

but it come with different path when i type http://localhost:8080/bbs and http://localhost:8080/bbs/index.jsp.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are all those $ etc.? That just looks horrible :(
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4122
195
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lek Kin Wong wrote: this is the jsp code how i get the parent path

Using Java codes (scriptlets) inside JSPs is highly discouraged. You should separate the business logic of your application and make the JSPs only as the viewer components.
 
Surajsingh Thakur
Ranch Hand
Posts: 124
Eclipse IDE MySQL Database Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In J2EE, use of the MVC model is highly encouraged
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As previously noted, your variable names are horrendous. All that file$ nonsense is completely unnecessary and just makes your code really hard to read.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic