This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException  RSS feed

 
Lek Kin Wong
Ranch Hand
Posts: 30
  • 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
Marshal
Posts: 5563
709
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are all those $ etc.? That just looks horrible :(
 
Devaka Cooray
Marshal
Posts: 5563
709
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • 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
  • 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
Posts: 66204
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!