response图片下载...字节输出错误?

!图片下载错误请求不到是路径错了还是](https://img-ask.csdn.net/upload/201507/27/1437976537_395357.jpg)

 package cn.kakabuli.android.response;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 中文名文件下载
 */
public class Demo07 extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //服务器要求浏览器以下载方式打开资源
        String filename = "广州地铁线路图.jpg";
        //中文文件名要进行编码
        filename = URLEncoder.encode(filename, "UTF-8");
        response.setHeader("content-disposition", "attachment;filename="+filename);
        //以下代码就是用流的方式,将服务器的文件输出到浏览器中
        InputStream is = this.getClass().getClassLoader().getResourceAsStream("../../images/广州地铁规划图.jpg");
        OutputStream os = response.getOutputStream();
        byte[] buf = new byte[2048];
        int len = 0;
        while((len=is.read(buf))>0){
            os.write(buf, 0, len);
        }
        os.close();
        is.close();
    }

}

download.html

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>download.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <style type="text/css">
        a:link{
            text-decoration:none
        }
        a:hover{
            text-decoration:underline;
            color:red   
        }
    </style>
  </head>
  <body>

    广州地铁图.jpg

    &nbsp;&nbsp;&nbsp;

    <!-- 
        /表示webapps目录
    -->
    <a href="/shulan-day07_request_response/Demo07">下载</a>

  </body>
</html>

http报500的错误,说明是服务器内部出现问题,而且报错信息为NullPointerException,在第35行出错,说明35行的位置,对象为空,应该是获取到的图片为空吧

/ 获取当前目录的图片路径
// String path=this.getServletContext().getRealPath("/image/tuxing.png");
String path=this.getServletContext().getRealPath("/image/水星.png");
// 获取文件名
String fileName=path.substring(path.lastIndexOf("\")+1);
System.out.println(fileName);
//制定浏览器头
//在下载的时候这里是英文是没有问题的
//resp.setHeader("content-disposition", "attachment;fileName="+fileName);
//如果图片名称是中文需要设置转码
resp.setHeader("content-disposition", "attachment;fileName="+URLEncoder.encode(fileName, "UTF-8"));

运行过程错误,空指针异常,debug调试下那个null了