Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Websphere上的NullPointerException异常?_Java_Servlets_Websphere - Fatal编程技术网

Java Websphere上的NullPointerException异常?

Java Websphere上的NullPointerException异常?,java,servlets,websphere,Java,Servlets,Websphere,我使用PrintWriter调用了另一个servlet。无法重定向特定的目标URL。我的代码是 PrintWriter pw= null; pw= response.getWriter(); pw.print("URL TO Redirect"); pw.close(); Websphere SystemErrorLog: java.lang.NullPointerException at com.ibm.ws.http.channel.inbound.impl.HttpInbound

我使用PrintWriter调用了另一个servlet。无法重定向特定的目标URL。我的代码是

PrintWriter pw= null;
pw= response.getWriter();
pw.print("URL TO Redirect");
pw.close();
Websphere SystemErrorLog:

java.lang.NullPointerException
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:485)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:301)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:275)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:557)
        at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:607)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:984)
    at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1069)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1563)

pw.close
应该是
pw.close()

否则,您将尝试访问名为
close
的非私有字段。如果存在这种情况,则可能是
null


除此之外,您的代码看起来不错,NPE的原因在其他地方。

是否与您可以显示更多的代码相同?什么是
响应
?@gaurav5430,连接可能过早关闭是否导致此异常???@RyanCarlson查看链接连接可能过早关闭是否导致此异常?在请求完成之前,我们正在关闭连接。。。请参阅链接