S
Steve R. Burrus
CAN someone help me with this problem of always getting the NPE whenever I
try to view only this particular servlet image in my browser. Here [AGAIN] I
submit the code for this servlet, if someone didn't see it the other day
when I initially posted this :
package com.laundry.gal;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LuvThisGal extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws
ServletException, IOException {
response.setContentType("image/jpeg");
ServletContext cnt = getServletContext() ;
InputStream is = cnt.getResourceAsStream("/GirlAtSink.jpeg");
int read = 0;
byte[] bytes = new byte[1024];
OutputStream os = response.getOutputStream ();
while(( read = is.read(bytes)) != -1) {
os.write(bytes, 0, read);
}
os.flush();
os.close();
}
}
****************************************************************************************************************************************************
java.lang.NullPointerException
at com.laundry.gal.LuvThisGal.doGet(LuvThisGal.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
icationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
ilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapper
alve.java:214)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContext
alve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.
ava:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.
ava:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVa
ve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.ja
a:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.jav
:825)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proc
ssConnection(Http11Protocol.java:738)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndp
int.java:526)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFo
lowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Thread
ool.java:684)
at java.lang.Thread.run(Thread.java:595)"<<
try to view only this particular servlet image in my browser. Here [AGAIN] I
submit the code for this servlet, if someone didn't see it the other day
when I initially posted this :
package com.laundry.gal;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class LuvThisGal extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws
ServletException, IOException {
response.setContentType("image/jpeg");
ServletContext cnt = getServletContext() ;
InputStream is = cnt.getResourceAsStream("/GirlAtSink.jpeg");
int read = 0;
byte[] bytes = new byte[1024];
OutputStream os = response.getOutputStream ();
while(( read = is.read(bytes)) != -1) {
os.write(bytes, 0, read);
}
os.flush();
os.close();
}
}
****************************************************************************************************************************************************
java.lang.NullPointerException
at com.laundry.gal.LuvThisGal.doGet(LuvThisGal.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(App
icationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(Application
ilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapper
alve.java:214)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContext
alve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.
ava:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.
ava:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVa
ve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.ja
a:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.jav
:825)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proc
ssConnection(Http11Protocol.java:738)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndp
int.java:526)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFo
lowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Thread
ool.java:684)
at java.lang.Thread.run(Thread.java:595)"<<