NullPointerException when setting attribute?

后端 未结 5 607
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 05:17

For example I have a servlet code that sets attribute to a HttpServletRequest:

request.setAttribute(\"someValue\", someValue());
        RequestDispatcher rd         


        
5条回答
  •  無奈伤痛
    2020-12-19 06:03

    I'm not sure what this has to do with it being thread safe.

    The exception you're getting is a NullPointerException it looks like Tomcat is trying to invoke a method on a null object.

    In a Java web application each request has its own HttpServletRequest instance, so you can set the attributes on the request and be confident it is only for that user.

提交回复
热议问题