S
Steve R. Burrus
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();
}
}
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();
}
}