cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ugo Cei <>
Subject Re: Discussion of Flow Issues
Date Tue, 18 Mar 2003 11:52:12 GMT
Sylvain Wallez wrote:
> Ugo Cei wrote:
> This is something that I don't fully understand : when you call 
> cocoon.createSession(), global variables of the various scripts of a 
> given sitemap are shared through the session. This means, AFAIU, that 
> each user has then its own independent set of global variables. Is this 
> right ?


> But to what are these global variables attached when 
> cocoon.createSession() hasn't been called ?

I suppose they are relevant only for the current request, thus a new set 
is created with each request.

> Session are always available through the good old 
> "request.getSession()". But I'd like to avoid the session to be created 
> implicitly by the flow engine since not every application needs it.
> Sylvain

Uhm yes, I could always create a session via the request and call 
session.setAttribute()/getAttribute() on it. I could avoid global 
variables and attach objects that I want to persist across requests to 
that session. This means that instead of doing:

var user;

function login(username) {
	user = UserManager.getUser(username);

function chpasswd(newpasswd) {
	user.password = newpasswd;;

I'd have to write:

function login(username) {
	var user = UserManager.getUser(username);
	var session = request.getSession(true);
	session.setAttribute("user", user);

function chpasswd(newpasswd) {
	var user = session.getAttribute("user");
	user.password = newpasswd;;

I don't know about you, but I prefer the former.


Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail:

View raw message