Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2005

Tip: Looking for answers? Try searching our database.

STILL Need Help w. NullPointerException.

Thread view: 
Steve R. Burrus - 24 Mar 2005 05:57 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 :

                     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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.