Java Websphere上的NullPointerException异常?
我使用PrintWriter调用了另一个servlet。无法重定向特定的目标URL。我的代码是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 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查看链接连接可能过早关闭是否导致此异常?在请求完成之前,我们正在关闭连接。。。请参阅链接