cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <>
Subject RE: getxml in XSP throws NPE if @path is invalid
Date Tue, 14 Oct 2003 09:30:48 GMT
Tuomo L dijo:
> Here's the line of code, that gives the error (No error, if
> /authentication/data/bar/ is actually available. The "data" section is
> created dynamically for every user, so "bar" is not always there and
> error happens)
> String foo = <xsp-session-fw:getxml context="authentication"
>              path="/authentication/data/bar"/>;

Hi Tuomo:

There is another attribute that can help you:

as="string" (default) - returns the value of the given path as a String.

as="object" returns the value of the given path as an Object

as="xml" returns the value of the given path as an
org.w3c.dom.DocumentFragment. The root of the DocumentFragment is

Are you tried this attribute? Maybe it can helps you.

The idea of the default as="string" is to let you add easily inside your
XSP some strings. We are using to show the user name in a welcome page.

<p>Hi <xsp-session-fw:getxml context="authentication"
      path="/authentication/data/full_name"/>, welcome back to the System</p>

Of course in this example the @path always exists, so we don't need to
test if the @path exists in the given session context.

So, I recommend you use as="object", get the object and if the object is
null, then there is nothing. Else the path exists so you can get the

Please comment if this works for you. I am not sure if this will work,
since Carsten did changes in the Helperclass in order to helps you.

Best Regards,

Antonio Gallardo.

View raw message