cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <>
Subject Re: I'm confused about XSP , variables and session
Date Mon, 02 Jul 2001 10:41:08 GMT
On 29.Jun.2001 -- 12:21 PM, wrote:
> For instance , I have a XSP logicsheet that declares:
> String person = request.getParameter("person");
> I then use this variable in a custom XSP tag library that is declared in
> the namespace of the XSP logicsheet. Is this possible because the "person"
> variable is static?
> Also, In my XSP tag library that I created, I have instantiated several
> variables:
> private String sPrefix;
> private String sFirstName;
> private String sLastName;
> private String sMiddleName;
> These variables are behaving like static variables. Every session on the
> webserver will be looking at the same variable in the tag library. I wanted
> to use tag library because I really like the notion of separating content
> and logic and tag library made this very easy by just dropping in dynamic
> data place holders in your XML. But if every session is looking at one
> static variable in my tag library, then I can't use tag libraries the way I
> want.
> I was hoping somebody could explain the scope of variables declared in XSP
> taglibs versus variables declared in logicsheets.
> I basically want variables that persist only in a specific session.

Think of logicsheets aka TagLibs as macros -- that's what they
are. They are no functions to call. Tags on your XSP get *replaced* by
the contents of the tag definition in your logicsheet (this is not
100% accurate since it is possible to do some simple programming
e.g. <xsl:for-each>).

At the end of the process, one file (a java class) is produced that
combines the code snippets from your XSP and the logicsheets used.
Looking at this file is very interesting and will help you
understand. I believe the "concepts" section describes this very
well. Thus variables in logicsheets and XSPs basically have the same

BTW this is the reason why it is no good idea to declare variables in
logicsheets -- clashes might appear e.g. when a tag that declares a
variable is used more than once on a XSP. Extra care must be taken to
do this safely.

All variables that have not been declared "static" should be
reinitialized for every request.

For variables to persist in a specific session, they must be added and
retrieved from the session. There's a taglib provided with cocoon2
that does that.


C h r i s t i a n       H a u l
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

Please check that your question has not already been answered in the
FAQ before posting. <>

To unsubscribe, e-mail: <>
For additional commands, e-mail: <>

View raw message