我使用PrintWriter对另一个servlet进行servlet调用。无法重定向特定目标URL。我的代码是
PrintWriter pw= null;
pw= response.getWriter();
pw.print("URL TO Redirect");
pw.close();
Websphere 系统错误日志:
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
的非私有(private)字段。如果存在的话,它可能是null
。
除此之外,您的代码看起来不错,NPE 原因在其他地方。
关于java - Websphere 中的 NullPointerException 异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20999027/