I posted this problem to the group the other nite, but alas, since it still
persists as a problem for me, I thought that i would re-submit it for anyone
to try to help me with it. The problem is still getting a server error
pointing to a "NullPointerException"!!! I really don't see at all any kind
of a null object reference or any problem like that could lead to such an
exception in this file :
package org.my.servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class My_Image extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("image/jpeg");
ServletContext con = getServletContext();
InputStream in = con.getResourceAsStream("/MyBeautifulGirl1.jpeg");
int read = 0;
byte[] bytes = new byte[1024];
OutputStream os = resp.getOutputStream() ;
while(( read = in.read(bytes)) != -1){
os.write(bytes, 0, read);
}
os.flush();
os.close();
}
}
Wendy S - 24 Mar 2005 06:06 GMT
>I posted this problem to the group the other nite, but alas, since it still
>persists as a problem for me, I thought that i would re-submit it for
>anyone to try to help me with it. The problem is still getting a server
>error pointing to a "NullPointerException"!!! I really don't see at all any
>kind of a null object reference or any problem like that could lead to such
>an exception in this file :
Neither do we, since you STILL didn't identify the line on which the NPE is
occurring.

Signature
Wendy
Hikikomori - 24 Mar 2005 10:07 GMT
My magic 8 ball says that the getResourceAsStream method returned a
null because the resource could not be found. So your InputStream
object was null and you tried to use it and a npe was thrown. Tada!
Of course, that's just what my magic 8 ball says.
Tor Iver Wilhelmsen - 24 Mar 2005 11:14 GMT
> Of course, that's just what my magic 8 ball says.
My crystal ball concurs.
Big Jim - 24 Mar 2005 21:25 GMT
>> Of course, that's just what my magic 8 ball says.
>
> My crystal ball concurs.
my bouncy ball bounces
Ryan Stewart - 25 Mar 2005 01:44 GMT
>> Of course, that's just what my magic 8 ball says.
>
> My crystal ball concurs.
As did mine the last time he posted this, but I never received any response to
that post.