Re. Null Pointer Exception.
From: Steve R. Burrus (burrus1_at_swbell.net)
Date: 03/29/05
- Next message: Lee Fesperman: "Re: mysql and jdbc"
- Previous message: Lee Fesperman: "Re: A better cloning mechanism (was: Why not cloneable by default?)"
- Next in thread: kjc: "Re: Re. Null Pointer Exception."
- Reply: kjc: "Re: Re. Null Pointer Exception."
- Reply: klynn47_at_comcast.net: "Re: Re. Null Pointer Exception."
- Reply: Patricia Shanahan: "Re: Re. Null Pointer Exception."
- Reply: Anton Spaans: "Re: Maybe this is the issue:"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 29 Mar 2005 20:39:02 GMT
I know that SOME of you think that I am being "crazy" and foolhardy by still
posting my problem about getting that "java.lang.NullPointerException"
almost every time that I try/attempt to view a servlet image in my browser,
but I swear, I have looked OVER AND OVER at the lines in the servlet file
which I suspect could be giving me this server error, but I honestly could
not find the problem! Truth In Representation : I HAVE been able to view
just a few of the images successfully, but I really don't know why. Well,
with my apologies to those of you who don't feel like I need again the
servlet code, I humbly re-submit it to you :
package com.laundry.gal;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LuvThisGal extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws
IOException,ServletException {
response.setContentType("image/jpg");
ServletContext ctx = getServletContext();
InputStream is = ctx.getResourceAsStream("/GirlAtSink.jpeg");
int read = 0;
byte[] bytes = new byte[1024];
OutputStream os = response.getOutputStream();
while((read = is.read(bytes)) != -1) {
os.write(bytes, 0, read);
response.sendError(500,"Hey! Your Servlet Developed A" +
"NullPointerException.");
}
os.flush();
os.close();
}
}
- Next message: Lee Fesperman: "Re: mysql and jdbc"
- Previous message: Lee Fesperman: "Re: A better cloning mechanism (was: Why not cloneable by default?)"
- Next in thread: kjc: "Re: Re. Null Pointer Exception."
- Reply: kjc: "Re: Re. Null Pointer Exception."
- Reply: klynn47_at_comcast.net: "Re: Re. Null Pointer Exception."
- Reply: Patricia Shanahan: "Re: Re. Null Pointer Exception."
- Reply: Anton Spaans: "Re: Maybe this is the issue:"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|