aspose 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: 3100
    
  40

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
What would SCJP exam questions look like? -- Home -- Twitter -- 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: 3100
    
  40

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: 61216
    
  66

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