File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes java.lang.NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java.lang.NullPointerException" Watch "java.lang.NullPointerException" New topic
Author

java.lang.NullPointerException

Lek Kin Wong
Ranch Hand

Joined: Feb 23, 2010
Posts: 30


What the problem with this code, i got a java.lang.NullPointerException with it on my Tomcat7.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

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.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Lek Kin Wong
Ranch Hand

Joined: Feb 23, 2010
Posts: 30
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

Joined: Sep 29, 2008
Posts: 12617

What are all those $ etc.? That just looks horrible :(
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

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

Joined: Sep 09, 2008
Posts: 124

In J2EE, use of the MVC model is highly encouraged


BE (Computer Science) SCJP 4 (80%) SCWCD 5 (97%) IBM CAD(98%) IBM CAppD(100%) IBM SD(100%)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

As previously noted, your variable names are horrendous. All that file$ nonsense is completely unnecessary and just makes your code really hard to read.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPointerException
 
Similar Threads
Finding a folder or a file
trouble with Runtime.exec()
Ranchers,Clarification on UTF-8 in Java
How to zip files and folders in a directory into 1 zip file?
How do I read an entire file all at once?