java - null point exception when I try to open a file -


i want open file servlet

i have function return type byte[]

and have jps file contain button , when click in button methode (consult) called try code

public class test{      private httpservletrequest request;       private httpservletresponse response;  public void consult() {          p8connector connector = new p8connector(typeenum.ce.value(),                 "test");           getdocumentslistinfolder getdocumentslistinfolder = new getdocumentslistinfolder();         list<document> list = new arraylist<document>();          list = getdocumentslistinfolder.execute(connector,                 "/test", "1");           (int = 0; < list.size(); i++) {             document doc = (document)list.get(i);             getdocumentcontent c = new getdocumentcontent();            byte[] =  c.execute(connector , doc);       response.setheader("expires", "0");       response.setheader("cache-control", "must-revalidate, post-check=0, pre-check=0");          response.setheader("pragma", "public");           response.setcontenttype("application/pdf");            inputstream in = new fileinputstream("20130114.008.01.pdf");            outputstream out = response.getoutputstream();             // copy bits instream outstream            byte[] buf = new byte[1024];            int len;            while ((len = in.read(buf)) > 0) {               out.write(buf, 0, len);            }            in.close();  }  public void setservletrequest(httpservletrequest request){           this.request = request;           }            public httpservletrequest getservletrequest(){           return request;           }            public void setservletresponse(httpservletresponse response){           this.response = response;           }            public httpservletresponse getservletresponse(){           return response;           }  } 

but when run code have

this erreur : null point exception

in line

   response.setheader("expires", "0"); 

who call setservletresponse ? seems nobody, response null.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -