简体   繁体   English

Websphere的NullPointerException异常?

[英]NullPointerException exception at Websphere?

I have servlet call to another servlet Using PrintWriter .Unable to redirect particular target URL.My code is 我有servlet调用另一个servlet使用PrintWriter .Unable来重定向特定的目标URL。我的代码是

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

Websphere SystemErrorLog: 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; should be pw.close(); 应该是pw.close(); .

Otherwise you're trying to access a non-private field, named close . 否则,您正在尝试访问名为close的非私有字段。 And if such exists, it's possible it's null . 如果存在,那么它可能是null

Apart from that, your code looks fine and the NPE reason is somewhere else. 除此之外,您的代码看起来很好,NPE的原因在于其他地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM