cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Rocha <rica...@apache.org>
Subject Re: nullpointerexception when trying to session.setAttribute
Date Mon, 28 Aug 2000 23:39:58 GMT
Make sure your XSP page is set to create the session object:

  <xsp:page ... create-session="true">
    . . .
  </xsp:page>

The default is not to create a new session. The above form
ensures the XSP code generator emits code to create the
session

Steve Conover wrote:
> 
> sorry about all the posts...
> 
> I'm having a problem setting a session variable - I'm getting a
> nullpointerexception back from cocoon on the line where I do the
> setAttribute.  It's a pretty basic example, I've taken a look at the .java
> file in my servlet engine's repository and the code looks ok there too.
> Here's my code:
> 
> <xsp:logic><![CDATA[
>                                 if (checkSecurity(request))
>                                         {
> 
> 
>                                                 boolean useridExists =
> false;
> 
>                                                 try
>                                                         {
>                                                                 String s =
> (String)session.getAttribute("userid");
>                                                                 useridExists
> = true;
>                                                         }
>                                                 catch (Exception e)
>                                                         {
>                                                                 useridExists
> = false;
>                                                         }
> 
>                                                 if ( !useridExists &&
> request.getParameter("userid") != null)
>                                                         {
>                                                                 String s =
> "117";
> 
> session.setAttribute("userid2", "abc"); //generates nullpointer exception
> ????
>                                                         }
>                                                  ]]>
>                                                 <xsl:copy>
> 
> <xsl:apply-templates/>
>                                                 </xsl:copy>
> 
>                                         }
>                                 else
>                                         {
>                                                 <securityexception/>
> 
> <xsp:expr>writeToLog("security exception: referrer_ip=" +
> request.getHeader("REMOTE_ADDR").trim() + " local_ip=" +
> request.getHeader("LOCAL_ADDR").trim());</xsp:expr>
> 
> <xsp:content><xsp:expr>request.getHeader("REMOTE_ADDR").trim()
> </xsp:expr><xsp:expr>request.getHeader("LOCAL_ADDR").trim()</xsp:expr></xsp:
> content>
>                                         }
>                         </xsp:logic>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

Mime
View raw message