Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerExcepiton error while reading text file under /WEB-INF/readME.txt  RSS feed

 
Hitesh Patel Patel
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I am getting an error trying to resolve but could not. Please help if you can.

1. Text file is located under /WEB-INF/readME.txt

2. Here is the JSP file that trying to read text file but INPUTSTREAM object always returns NULL.



As you can see I have tried to use INPUTSTREAM object in 2 different ways using CONTEXT and using CLASSLOADER but it does not work either.

Looking forward to getting someone's reply.

Thanks - Hitesh
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try not having WEB-INF in the file name just "/readME.txt".
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Try not having WEB-INF in the file name just "/readME.txt".

No, the path is expected to be relative to the context root.

Why is this code in a JSP rather than a servlet?
 
Hitesh Patel Patel
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Surprise! Surprise! Surprise!

I tested the same code on my work computer but this time I kept file name as "readMe.txt" instead of "readME.txt".
It worked straight away.

Then I thought this is not OK since file name can be any so I made it "HITESH.txt" and it was still working.

This is weird but came to conclusion that Tomcat does not like "readME.txt" but "readMe.txt" is fine.

Thanks,
Hitesh
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66187
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the file's real name?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!