Martin Gainty wrote:
> Well bs chuck and laughing dave
>
> I ran your exact example / deleted FunkyImage.jpg and got this on screen
>
>
java.lang.NullPointerException> coreservlets.ImageFile.doGet(ImageFile.java:34)
>
javax.servlet.http.HttpServlet.service (
HttpServlet.java:689)
>
javax.servlet.http.HttpServlet.service (
HttpServlet.java:802)
>
> **********But wait a minute Im NOT supposed to get NullPointerException
> !!!!!***********
>
> public class ImageFile extends HttpServlet
> {
> public void doGet( HttpServletRequest rq, HttpServletResponse rp ) throws
> ServletException, IOException // public static void main(String[] args)
> {
> //
javax.servlet.http.HttpServletResponse rp;
> //
javax.servlet.http.HttpServletRequest rq;
> ServletContext sc;
>
> rp.setContentType( "image/jpeg" );
>
> sc = getServletContext ();
> InputStream in = sc.getResourceAsStream("FunkyImage.JPG");
>
> int r = 0;
> byte[] by = new byte[4096];
>
> OutputStream os = rp.getOutputStream();
>
> if (in==null) System.out.println("This is when in == null");
>
> while( ( r = in.read(by)) != -1)
> {
> if (in==null) System.out.println("This is when in == null");
> os.write(by, 0, r);
> }
> os.flush();
> os.close() ;
> } //DoGet
> } //ImageFile
>
> How is it that (in==null) didnt evaluate true ?
>
> Comments?
Aren't you the one who recently offered a programming duel?
Regards
mks
---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)