4 Replies Latest reply: Apr 28, 2010 5:31 PM by user753546 RSS

    Setting request attribute

      In ServletRequest javadoc (2.5) the setAttribute(String,Object) has the following text:

      "If the object passed in is null, the effect is the same as calling removeAttribute(java.lang.String)."

      When doing a setAttribute with null value in OCCAS it throws a NPE.

      Is the SipServletRequest specified differently?

        • 1. Re: Setting request attribute
          Can you be specific which sip server release you are using and also put a exception trace here.
          • 2. Re: Setting request attribute
            I see you mention OCCAS in your thread.

            But here is what javadoc says for sip servlets


            void setAttribute(java.lang.String name,
            java.lang.Object attribute)

            Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

            name - the name to which the object is bound; cannot be null
            attribute - the object to be bound; cannot be null
            java.lang.IllegalStateException - if this method is called on an invalidated session
            java.lang.NullPointerException - on null name or attribute.

            So both name and value cannot be null
            • 3. Re: Setting request attribute
              That was unexpected!

              My problem is not related to SipSessions but the SipServletRequest.setAttribute has the same text.

              OCCAS is doing the right thing! But this has to be a bug in JSR-289 since the base interface from Servlet API 2.3 (which is referred by JSR-289) says that ServletRequest.setAttribute should accept null value and act as removeAttribute. The SipServletRequest is not honoring the contract defined by the interface it extends.

              But in the end OCCAS is doing the right thing according to JSR-289 and I have to spend a long night doing null checks. :-)

              • 4. Re: Setting request attribute
                oops..my fault I didnot properly check the object .
                But as you have written same applies for SipRequest also as per jsr289 .