I dont think you can use special characters as your filename
so ren your image to image.jpg then re-get using

 logo = getServletContext().getResourceAsStream("image.jpg");

M-
This e-mail communication and any attachments may contain confidential and 
privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you 
are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, 
distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Steve R Burrus" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Sunday, November 12, 2006 7:06 PM
Subject: Re: How do I ........?


> here is the entire code for the image servlet which I seem to be 
> repeatedly getting that NullPointerException java exception. Any ideas 
> what the problem is ? :
> 
>                            package coreservlets;
> 
>                             import java.io.*;
>                             import javax.servlet.*;
>                             import javax.servlet.http.*;
> 
> public class Image_File extends HttpServlet {
>     public void doGet( HttpServletRequest rq, HttpServletResponse rp ) 
> throws
>                                                       ServletException, 
> IOException {
>        rp.setContentType( "image/jpeg" );
> 
>        ServletContext sc = getServletContext ();
>        InputStream in = sc.getResourceAsStream("/Sexy_Laundry_Girl!.JPG");
> 
>        int r = 0;
>        byte[] by = new byte[4096];
> 
>        OutputStream os = rp.getOutputStream();
>        while( ( r = in.read(by)) != -1) {
>             // if (r in= null)
>            os.write(by, 0, r);
>       }
>       os.flush();
>       os.close() ;
>   }
> }
> 
> 
> Martin Gainty wrote:
> 
>>you can always wrap your accesor in a simple try/catch block as in
>>try
>>{
>> Image logo=null;
>>  logo = Toolkit.getDefaultToolkit().getImage("images/splash.png");
>>}
>>catch(NullPointerException excp)
>>{
>> log.debug("NullPointerException thrown while retreiving image 
>> images/splash.png");
>> System.out.println("NullPointerException thrown while retrieving 
>> images/splash.png");
>>}
>>
>>Anyone else?
>>
>>M-
>>This e-mail communication and any attachments may contain confidential and 
>>privileged information for the use of the 
>>designated recipients named above. If you are not the intended recipient, you 
>>are hereby notified that you have received
>>this communication in error and that any review, disclosure, dissemination, 
>>distribution or copying of it or its 
>>contents
>>----- Original Message ----- 
>>From: "Steve R Burrus" <[EMAIL PROTECTED]>
>>To: <users@tomcat.apache.org>
>>Sent: Sunday, November 12, 2006 5:52 PM
>>Subject: How do I ........?
>>
>>
>>  
>>
>>>I know that this question of  mine has been asked/answered in this 
>>>group, but I was wondering how do I go about checking for a null value? 
>>>I feel the need to do this in a servlet file that incorporates an image 
>>>into it.
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To start a new topic, e-mail: users@tomcat.apache.org
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>    
>>>
>>>
>>
>

Reply via email to