tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve R Burrus <burr...@swbell.net>
Subject Need Help w. Null Pointer Exception.
Date Wed, 30 Aug 2006 04:08:09 GMT
I need some pretty immediate help/assistance with always getting a 
NullPointerException Java exception when I try to view a particular 
image in my favorite web browser!!! The line of text in my servlet file 
which is, I think, problemmatic is a while loop. Well here is my entire 
servlet file for someone to take a look at to hopefully help me with 
this problem.

                     package org.stephen.burris;

                         import java.io.*;
                         import javax.servlet.*;
                         import javax.servlet.http.*;

  public class One_More_Time extends HttpServlet {
     public void doGet(HttpServletRequest rq, HttpServletResponse rp ) 
throws
                       ServletException, IOException {
        rp.setContentType( "image/jpeg" );

        ServletContext sc = getServletContext ();
        InputStream is = sc.getResourceAsStream("/pamandersonnaked.jpeg");

        int read = 0;
        byte [] bytes = new byte[ 1024 ];

        OutputStream os = rp.getOutputStream ();
        while ((read = is.read(bytes)) != -1) {
        os.write( bytes, 0, read);
        }

        os.flush();
        os.close();
   }
}

And the server error : 


  HTTP Status 500 -

------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented 
it from fulfilling this request.

exception

java.lang.NullPointerException
	org.stephen.burris.One_More_Time.doGet(One_More_Time.java:19)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache 
Tomcat/5.5.17 logs.

------------------------------------------------------------------------


      Apache Tomcat/5.5.17



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message